View Single Post
  #3  
Old March 3rd, 2010, 11:39 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Restarting Record Count in a Query

Try this --
SELECT [Badge No], [DepLastName], [DepFirstName], (SELECT Count(*) FROM
YourTable AS [XX] WHERE [XX].[Badge No] = YourTable.[Badge No] AND
[XX].[DepLastName] & [XX].[DepFirstName] = YourTable.[DepLastName] &
YourTable.[DepFirstName] ORDER BY [XX].[Badge No], [DepLastName] &
[DepFirstName]) AS [Count]
FROM YourTable
ORDER BY [Badge No], [DepLastName], [DepFirstName];

I included the last and first names in combination as there may be a family
that has multiple last names.

--
Build a little, test a little.


"Bill B." wrote:

Hello,

I have a query that returns these results for me:

Badge No DepLastName DepFirstName
11111 Smith Mary
11111 Smith Joe
22222 Brown Bill
22222 Brown Mary
22222 Brown Jack

I need to count the dependents that are linked to each Badge No so my
results look like this

Badge No Count DepLastName DepFirstName
11111 1 Smith Mary
11111 2 Smith Joe
22222 1 Brown Bill
22222 2 Brown Mary
22222 3 Brown Jack

I don't have much experience with modules and functions to accomplish this.
Is there anyway this can be done. Thanks!

Bill B.