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!

Need to count records 1

Status
Not open for further replies.

tarena

IS-IT--Management
Nov 28, 2005
70
0
0
US
I am using Access 97 and I need to count the number of records by part number. Can this be done with one query? The Fields I have in my table are "PartNum" and "SerialNum". I need to count how many "SerialNum" entries are made for each "PartNum". I tried the DCount but it only added the total records. Any help?

Thank you
Tarena
 
Yoiu can do in simply select query. Use the totals (sigma) option on the Query Design toolbar

Group by PartNum and count SerialNum
 



Or try punching in SQL something like

Code:
select partnum, count(serialnum)
from yourdatabase
group by partnum
order by partnum
 
I tried the DCount but it only added the total records.

Just curious - did you use the WHERE parameter in your DCount? Seems like it could have worked, although I like the above suggestions better...

"Artificial Intelligence is no match for Natural Stupidity"
 
Alright, to do the simple query do I add any fields or just add the table and then just build the expression?
 
What BigRed1212 gave you will do it although you probably want to give the count a field alias.
Code:
Select partnum, count(serialnum) [blue]As [CountofSerialnum][/blue]
from yourdatabase
group by partnum
order by partnum
Change "yourdatabase" to the name of the table.
 
Your table needs to be added to the table first, then you need to add your two fields to the design grid, then apply the totals as above

Take it Easy
Man with one chopstick go hungry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top