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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating the amount of records returned

Status
Not open for further replies.

manners

Technical User
Jan 19, 2003
61
GB
Hello.

I am attempting to write a query that will search a table for a specific gender and then total the amount of people it finds, then rerun for the other gender and return both results so I can use them in a report. Is this possible?

Thanks in advance
 
You can use the DCount() function in VBA code or as an expression in a text box's Control Source property.
=DCount("*", "[red]tablename[/red]", "Gender='M'")

You can also use a GROUP BY query (a.k.a. Totals query) to get both values at once.
SELECT Gender, Count(*) FROM [red]tablename[/red]
GROUP BY Gender

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Thanks RickSpr, i've created a Totals query for the table and that seems to work. Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top