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

count command

Status
Not open for further replies.

baha

Programmer
Apr 16, 2002
28
0
0
US
Hi

I need a help in programming Count function. In short: I have a DB for a hospital, i have a table with the patients name, adress and etc, also i have a field for Service date.
I made a query and found out how many patients we have seen in different years using Service Date field. But it doesn't look proffessional, becoz when i run a query i can tell how many of patient we have seen looking at the number of entries, but i want to creat a command which will display a message saying total patients for 2000 = 20.

How i can do it, i think i need to use Count, but nothing is working so far.

Thanx

 
If you have a query that gathers patients by service date, save the query (I'll call it qryPatientVisits for now). Then, use the DCount domain aggregate function to count the number of rows in the query:

Msgbox "There were " & DCount("*","qryPatientVisits") & " for the year"

You can put this coding in the OnClick event of a command button so, when the button is pressed, the MessageBox will appear.
 
Thanks for the tip, but i have some more questions.
First i created a macro Msgbox "There were " & DCount("*","qryPatientVisits") & " for the year", then i created a new form and inserted command button which runs this macro, when i press the button it displays: Msgbox "There were " & DCount("*","qryPatientVisits") & " for the year".

Is there anything i have to put before or after.

I created Macro and Form, becouse i do not think i can but Command button in Query.

Thanks


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top