Solved

Access Table - Add Field To Auto Number Records, Resetting When Record Value Changes

Posted on 2013-01-25
3
818 Views
Last Modified: 2013-01-25
I have a table with a column of Item Numbers sorted by the item number.
I am tying to find a way to insert a column to number the records based on the item number.
For example,

Counter      Item Number
1                   AAA
2                   AAA
3                   AAA
4                   AAA
5                   AAA
1                   BBB
2                   BBB
3                   BBB
1                   CCC
2                   CCC
3                   CCC
4                   CCC
5                   CCC
etc.

Any help would be appreciated.
0
Comment
Question by:Scamquist
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 350 total points
ID: 38819488
you can do that in a query



select a.*, (select count(*) from tblData B where B.itemnumber=a.itemnumber and b.id >=a.id) as counter
from tblData as A
order by a.itemnumber
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 150 total points
ID: 38819554
To do this, you must have an autonumber ID field already present in the table (or some other unique field which provides a defined sort sequence).  So if you don't have one you must add one.

Then a query such as the one posted by Cap1 will number like records in a query.
Unless you have a further reason for doing so, there is no real need to update the table with this sequence value.
0
 
LVL 1

Author Closing Comment

by:Scamquist
ID: 38819663
Thank you both.  Capricorn1 had the right formula.  However, I did not have an ID field, so it was failing.  Added the ID (peter57r) and all was well with the world.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

738 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