473,320 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

dmax problem to create an autonumber + 1

116 100+
Hi
This is the second query I have had with Dmax. The first one I resolved as it was in a form and by using DMAX everytime I click for new record it gave a new order number ie dmax("ordernumber", "tbl_orders")+1.

This problem is quite different and I am hoping someone out there can advice.

I have a group of orders in a table. I tick a box to select which records I want to batch for that particular month. An update query then copies these records to a new table ready for batching.

My query is that each row needs to have a unique reference number. I cant use autonumber as I must specify the first number at the beginning. After that each record will increment by one.

Thanks for your help. Hope all this makes sense

jacc14
Jul 7 '07 #1
4 4558
puppydogbuddy
1,923 Expert 1GB
Hi
This is the second query I have had with Dmax. The first one I resolved as it was in a form and by using DMAX everytime I click for new record it gave a new order number ie dmax("ordernumber", "tbl_orders")+1.

This problem is quite different and I am hoping someone out there can advice.

I have a group of orders in a table. I tick a box to select which records I want to batch for that particular month. An update query then copies these records to a new table ready for batching.

My query is that each row needs to have a unique reference number. I cant use autonumber as I must specify the first number at the beginning. After that each record will increment by one.

Thanks for your help. Hope all this makes sense

jacc14
As long as ordernumber is unique, you can use DCount to generate number sequence in your query as shown below: Don't forget to add the other fields besides Sequence and ordernumber to your query

SELECT DCount("ordernumber", "tbl_orders","ordernumber <=" & [ordernumber]) AS Sequence, ordernumber
FROM tbl_orders
ORDER BY tbl_orders.ordernumber;
Jul 7 '07 #2
jacc14
116 100+
Hi there
Just had a go and understand how it works. Problem is that I am only selecting random records from the tbl_orders. As I dont want the first record the sequence is starting at number 2 . If I dont select the 4th record then the sequence is 1 , 2 , 3 , 5 and so on.

Hope this makes sense. Its as if I need to assign a unique number once the selected data has been transfered to the result table rather than before.

Thanks for your help
Jul 7 '07 #3
puppydogbuddy
1,923 Expert 1GB
Hi there
Just had a go and understand how it works. Problem is that I am only selecting random records from the tbl_orders. As I dont want the first record the sequence is starting at number 2 . If I dont select the 4th record then the sequence is 1 , 2 , 3 , 5 and so on.

Hope this makes sense. Its as if I need to assign a unique number once the selected data has been transfered to the result table rather than before.

Thanks for your help
Ok, you are correct. I did not realize you were picking random records. But, you can do the same thing with a text field as long as it is unique within the query. For example, if customerName is unique within the query.

SELECT DCount("customerName ", "tbl_orders"," customerName <=’” & [customerName] & "'") AS Sequence, ordernumber, customerName
FROM tbl_orders
ORDER BY tbl_orders. customerName;
Jul 8 '07 #4
jacc14
116 100+
Thanks for your help

There was no unique record as there are sometimes more orders for one customer.

I have now solved this by running an additional select query from the result table and putting in your original suggest Dcount and sequence method.

Finally got there in the end.

Many thanks
jacc14
Jul 8 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Apple | last post by:
May anyone can teach me how to assign a autonumber, I want to create a number that is starting with year(auto change to year 2006) + autonumber (eg. 2005-0001, 2005-0002)
2
by: Apple | last post by:
May anyone can teach me to assign a autonumber, I want to create a number that is starting with year (auto change to year 2006) + autonumber (eg. 2005-1001, 2005-1002 and so on)
2
by: Apple | last post by:
Is there anyone can help me to solve this problem? Thank!
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
4
by: dskillingstad | last post by:
I have a form with one textbox (PermitNumber) where the default value is: ...
2
by: junkaccount | last post by:
Hello, I currently have a field named QuoteNumber in a table named Quotes. The field is set as autonumber and is used to assign sequential numbers as users enter information in the table through...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
8
by: luanhoxung | last post by:
hi all! i want to create group text for showing my invoice number. the invoice no. is created by 3 parts. 1st part: autonumber increasing at each new record. 2nd part: 2 characters of current...
3
by: Ron | last post by:
Hi All, Okay, here's the deal: Access2000/WinXP. Have a database that's split, FE/BE with multiple users having FE and one of those users also has BE (still split though...). Have a form on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.