DataBase - Generate OrderNo by comparing the previous orders
Asked By mls via AccessMonster.com
08-Feb-10 06:45 PM

I want to combine master Order table and order_detail transactional table.
If my order_detail table has orders today then I want to give OrderNo
depending on the previous orders made by customer.
I need to combine both the tables and the resulting table should show only
transactional data with order_id, date_ordered and OrderNo. If there is no
entry in the master table then ???Orderno= Order 1??? and then I have to insert
this data into the master table as new record.
I have the following which works fine and gives the OrderNo, if there is a
order_id in the master table and shows blank if there is no entry in the
master table.
SELECT 'Order ' & (Count(orders.order_id)+1) AS OrderNo, orders.order_id INTO
tbl_ordertemp
FROM orders right JOIN order_detail ON orders.order_id = order_detail.
order_id
GROUP BY orders.order_id;
To be simple I need to do the following..
if first.Order_id then i = 0
i + 1;
if date_ordered ne NULL then
if i=1 then OrderNo ='Order 1'
else if i=2 then OrderNo='Order 2'
else if i=3 then OrderNo='Order 3'
else if i=4 then OrderNo='Order 4'
if abi
end
How can I achieve this?
Thanks in advance
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/201002/1
Database
(1)
OrderNo
(1)
First.Order
(1)
Tablesdbdesign
(1)
Transactional
(1)
Orders.order
(1)
Detail.order
(1)
Ordertemp
(1)
orange via AccessMonster.com replied to mls via AccessMonster.com
What is it that you are trying to solve?
Do you have a database of orders and order details without unique OrderNo?
I do not understand your request- sorry.
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/201002/1
mls via AccessMonster.com replied to orange via AccessMonster.com
Sorry for the confusion. You can ignore this message. I fixed this.
Thanks
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/201002/1
Jeff Boyce replied to mls via AccessMonster.com
Consider posting your solution...
Someone in the future may be looking for an answer and your solution may be
it.
Regards
Jeff Boyce
Microsoft Access MVP
--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.
Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.
You can thank the FTC of the USA for making this disclaimer
possible/necessary.
mls via AccessMonster.com replied to Jeff Boyce
My query posted earlier works perfectly..
SELECT 'Order ' & (Count(orders.order_id)+1) AS OrderNo, orders.order_id INTO
tbl_ordertemp
FROM orders right JOIN order_detail ON orders.order_id = order_detail.
order_id
GROUP BY order_detail.order_id;
--
Message posted via http://www.accessmonster.com
DataBase Library Database Firstly, I am not sure if Library database is the correct term. I am talking about Dbs to which you set a reference drew blanks last time. Now assuming I have several referenced (library?) databases in my main database, how do I get the names of all the forms in all the Dbs? CodeProject AllForms.Count gives me the correct number of forms if I am in that referenced database. What I think I need is a method of looping through all the different CodeProject names in the main database, but there is not a sort of CodeProjects parent object. Or somehow moving the focus And, No, there is not any parent object for all the code projects. Because each database only knows about its own objects (or documents), you have to use a procedure in each database to refer to the objects in that database. E.g. to open a form in
DataBase Might be outgrowing Access but daunted by SQL Server I am close to completing the of Excel spreadsheets that my little company uses (5 staff) into an all encompasing Access database and I was planning on splitting the database when I was finished to allow simaltaneous use of it by staff on our small to me that I am going to need to give staff access to this new database from remote locations (outside of our office network). Two staff members are regularly overseas, one been playing around with trying to link tables from remote locations (ftp path of the database on our Network Storage Device at the office) and needless to say - that do not It all started when I came across a very encouraging article on keeping your Access database as your front end application and linking to SQL Server database tables. I am finding it MUCH more complicated than I had hoped. Can anyone suggest a simpler way of achieving remote access to my database? I have at my disposal a Network Storage Device which has remote access capabilities (this
DataBase User Level Security Malfunction Hello! I have an Access 2003 database, and I ran the User Level Security Wizard on the database, and it all seemed to work fine. I get prompted to log in and the world is good. Later, I asked my other users to open the database, and it let them all in, without prompting for a UserID / Password. I did a Users / Group Permissions, its shows that I “successfully†made myself the owner of the database (different than the Admin user), assign the Admin a password, and that the Admin user wrong and how to I fix it? I have done this before on an Access2000 database had had no issues. The same articles also recommended that I create a new blank database with a new workgroup (manually) and import the old database objects. I got to the point of trying to import, then I got the error
DataBase Exporting Report from Access into PDF Hi everybody. I am hoping someone may be able to help me out. I have a database report that I want to export into PDF for each individual customer. Basically, I want time this source data changes. I am trying to work with Stephen Leban's A2000ReportToPDF database right now, but it is far more advanced than my puny range of code knowledge I am working with right now: Dim qdf As DAO.QueryDef Dim dbs As DAO.Database Dim rstMgr As DAO.Recordset, rstMgr1 As DAO.Recordset Dim strSQL As String, strTemp As Close strTemp = strQName ' * ** code to set strSQL needs to be changed to conform to your ' * ** database design - - ManagerID and EmployeesTable need to ' * ** be changed to your table and field names ' Get rstMgr.EOF = False ' * ** code to set strMgr needs to be changed to conform to your ' * ** database design - - ManagerNameField, ManagersTable, and ' * ** ManagerID need to be changed to your table and field names Acct#", "Customers_To_Email", _ ' * ** code to set strSQL needs to be changed to conform to your ' * ** database design - - ManagerID and EmployeesTable need to ' * ** be changed to your table and field names strSQL everybody. I am hoping someone may be able to help me out. I have a database report that I want to export into PDF for each individual customer. Basically, I want
DataBase Database Bloat Issues Looking for overview-level information about bloat. Have a chain of databases that pull raw data into tables, crunch it, store results in new tables, next database links to those tables, crunches some more, etc. At a couple points, the database bloats to the point that it fails at some step in the process. Have tried to put the temporary tables in yet another external database, more issues, yadda, yadda. If I understand it correctly, emptying a table doesn't solve or still reserved? And if I have the troublesome tables in a linked back end database, once I'm completely done with all those tables, can I run a repair and compact on that database while my "front end" is still open and running? What light can anyone shed on setting the query to "allow inconsistent updates, " but often that doesn't work. Jet (Access) database don't free up disk space, once they've allocated it, until a compact operation