Sequentially Number Records in Groups in an Access Query

I’m trying to create sequentially numbered groupings in an Access query.  To make this easier, I’ve created two small tables containing one field each, and one query to combine the two tables.

I’m not sure how to create sequentially numbered groupings in Access, but I do know how to do this in Excel, so I worked it out and included an example Excel file.  The three highlighted columns in the Excel file are examples of the three fields I'm trying to create in Access, which are:

1)      [TableOrder]
a.      Sequentially number the records returned by the query from 1 to whatever the total record count is (260)

2)      [ModuleGroup]
a.      Sequentially number the records by the groups created from the values in [Modules]
i.      The query is sorted by the [PRR] field, which is a concatenation of [Modules]&”-“&[Parts], and it can be used as a unique record identifier if one is needed

3)      [ModuleGroupOrder]
a.      Sequentially number the records from 1 to however many records are in each [ModuleGroup], then starting back over with 1 for each [ModuleGroup]

Thank you in advance for your help, Jon  
Jon BredensteinerProject ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


SELECT M.Modules, P.Part, [Modules] & "-" & [Part] AS PRR
     , (SELECT COUNT(1) FROM tblTestModules, tblTestParts WHERE M.[Modules] & "-" & P.[Part]>=[Modules] & "-" & [Part]) AS TableOrder
     , (SELECT COUNT(1) FROM tblTestModules WHERE M.[Modules]>=[Modules]) AS ModuleGroup
     , (SELECT COUNT(1) FROM tblTestModules, tblTestParts WHERE M.[Modules]=[Modules] AND P.[Part]>=[Part]) AS ModuleGroupOrder
FROM tblTestModules M, tblTestParts P
ORDER BY [Modules] & "-" & [Part];

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jon BredensteinerProject ManagerAuthor Commented:
You're the man Sage.  I've been trying to do this for like a year.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.