Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numbering Rows in my result set

Status
Not open for further replies.

NewCoder2

Programmer
Apr 12, 2004
25
0
0
US
How can I number rows/records in a record set?
Meaning, I have :
select id,name,address,phone#
from blah,blah,blah
where blah,blah,blah

My results could look like this:
ID Name Address Phone#
1 Ted 123anytown 1231231234
1 Ted 123anytown 1231231245
2 ED 789mystreet 5675675678

What I need is something I can add in the sql that will give me an indication of the # of rows containing that id number, like:
Row# ID Name Address Phone#
1 1 Ted 123anytown 1231231234
2 1 Ted 123anytown 1231231245
1 2 ED 789mystreet 5675675678
Any thought's would be appreciated. Thanks.
 
Something like this:

Num: DCount("ID","Blah","ID<='" & [ID] & "'")

ChaZ

Ascii dumb question, get a dumb Ansi
 
Correction:

Num: DCount("ID","Blah","[Phone#]<='" & [Phone#] & "' and [ID] = '" & [ID] & "'")

ChaZ

Ascii dumb question, get a dumb Ansi
 
I'm still new to Access, and I haven't verified this, so 'your mileage may vary'. Add another field to the query with Table = tablename, Field = Name, then click the backwards E in the menu bar. A line labeled 'Total' should appear in the query... For that field you just added, change "Group by" to Count. Rearrange the columns appropriately. It looks like you're already sorting by name, but verify that... your output should be what you're expecting.

Remember the discaimer, though.
 

Hummm.....I keep getting an automation error??
 
Can I see your SQL?

ChaZ

Ascii dumb question, get a dumb Ansi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top