Solved

Access query to provide a sequence number

Posted on 2014-03-03
4
1,487 Views
Last Modified: 2014-03-06
How do I add a field to a query that is a numerical sequence (1,2,3...) that resets back to 1 each time an item changes

P/N    Seq
1         1
1         2
1         3
2         1
2         2
3         1
0
Comment
Question by:Alphacircuits
  • 2
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39901956
you need a unique id for each record. [ID] in the query could be an autonumber field

select Yourtable.[P/N],(select count(*) from Yourtable as T where T.[P/N]=Yourtable.[P/N] and T.id>=Yourtable.ID) as Seq
from Yourtable
order by Yourtable.[P/N];
0
 

Author Comment

by:Alphacircuits
ID: 39903968
Ok, I have I added the ID to the table, but I am not sure where to insert the select statement you provided?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39904378
In your original post, you were asking for

Access query
0
 

Author Closing Comment

by:Alphacircuits
ID: 39910400
Thanks!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now