473,397 Members | 2,033 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,397 software developers and data experts.

Access - sequence number

2
Hi,

I am using Access 2003,how can I have a sequential counter in a query. No vba codes please.


profile_id account_num
1234 11111
1234 22222
3456 33333
3456 44444

I want the output as:

profile_id account_num Sequence
1234 11111 1
1234 22222 2
3456 33333 1
3456 44444 2

many thanks
ad
Jan 5 '15 #1
3 1274
twinnyfo
3,653 Expert Mod 2GB
ad,

Just add an additional field to your query which refers to itself and counts the number of records that match your criteria. For the following, I am assuming the name of your query (in your first list) is called "qryProfileAccounts". I am further assuming the Field names are "ProfileID", "AccountID" and "Sequence". Of course, you will have to modify the following to account for the true names. Additionally, assumption is that these first two fields are numeric.

Add a Field to your query as such:
Expand|Select|Wrap|Line Numbers
  1. DCount("[AccountID]","qryProfileAccounts", _
  2.     "[ProfileID] = " & [ProfileID] & _
  3.     " AND [AccountID] < " & [AccountID])+1 AS Sequence
Please let me know if this works and if you need further assistance.

Hope this hepps!
Jan 5 '15 #2
ad2015
2
Hi twinny

Im getting error as incorrect syntax. Appreciate if you can suggest a way to do this in Access 2003, using basic queries.

Else, please guide me with VBA for access 2003, im really new with sql.

Thanks a lot
Jan 6 '15 #3
twinnyfo
3,653 Expert Mod 2GB
Is the syntax error showing up in the Query builder? If you are building in the MS Access query builder, your field must be all on one line and will look like this:

Expand|Select|Wrap|Line Numbers
  1. Sequence: DCount("[AccountID]","qryProfileAccounts", "[ProfileID] = " & [ProfileID] & " AND [AccountID] < " & [AccountID])+1
Jan 7 '15 #4

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

Similar topics

2
by: Ken | last post by:
I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER" on Access could not create the sequence number as soon as the value has...
3
by: Robert McGregor | last post by:
Hi there, I was wondering if anyone could help with this problem. I have a table with about 250,000 rows that relate to files that have been processed elsewhere in our business. Each file has...
4
by: Kamran K | last post by:
Hello I have created a client server application using C#. Existing application is using random number on client side to generate sequence numbers that are then assigned to transactions. This...
12
by: tojigneshshah | last post by:
Hi, I have a situation where i have multiple batch and the each batch are sequence numbers. For each batch, the number should start with 1. For example: Col.no1 Col.no2 ------ ...
5
by: tojigneshshah | last post by:
Hi, How to restart sequence number once the data is imported/loaded into the tables? Please advise. regards Jignesh
1
by: ddice | last post by:
I need to update and then read a sequence number, but I think its failing when there are many users updating at the same time. Here's what I'm doing update datatable set nextnr = nextnr+1 where...
0
by: Mikelowe | last post by:
Would like to know is there an automated way to copy the maxvalue of sequence number from db2 production to db2 test. When we copy data from our production that uses a sequence number value as its...
21
by: bilgekhan | last post by:
After doing a succcessful insert() or find() on a set<Tcontainer is it possible to get the item number of this item in the set? (ie. its zero-based sequence number (position/location/rank/index)...
1
by: kama | last post by:
I want to create sequence number for repeating data values. This sequence number will re-start from 1 for each new value. Example as below:- Amount sequence_number 200 1 200 2...
2
by: fgwapo | last post by:
Hello, Need help in creating sequence number in a query using a starting number. For example i want to use the starting sequence number as 5 ------------------ Seqnum | color...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.