Solved

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

Posted on 2013-01-25
3
807 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
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 350 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

744 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

15 Experts available now in Live!

Get 1:1 Help Now