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

URGENT HELP NEEDED - PLEASE!!! 1

Status
Not open for further replies.

fallyhag

Technical User
Mar 31, 2001
78
GB
I'm no expert in MS Access.

My boss asked me to knock up a database to record all those who have done the mandatory Health & Safety Briefings.

So I knocked up the field headings as so:

Surname Passed test? Date Passed?
(Text) (Tick box) (Medium date format)

I can now produse a report with all those who have done it (ticked) and all those who havent (unticked).

My boss now needs to submit a percentage of all those who have passed the test.

My question is:

How do I count up the number of people in the database?

How do I count the number of ticks?



Thank you in advance for any help you can give.

Fallyhag
 
Create a text field in the report footer of your report. Set its format to "Percent" and choose how many decimal places of precision you prefer. For the control source of the field, enter this (all on one line):

Code:
=DCount("[Passed Test?]","tblMyTable","[Passed Test?] = True")/DCount("[Surname]","tblMyTable")

...where tblMyTable is the name of your table.

HTH...

Ken S.
 
After a lot of experimenting I seem to have got it to do the percentage. Thanks.

With regards to:

=DCount("[Passed Test?]","tblMyTable","[Passed Test?] = True")/DCount("[Surname]","tblMyTable")

Do you have the time to explain this "expression?" just I know for the future or want to modify it?

I would be very grateful.

Thanks again

Fallyhag
 
You're quite welcome. The DCount() function counts records in a given domain (i.e. table or query) based on whatever criteria you specify. The generic form of the expression is DCount("[field to count]", "table or query name that holds field to count", "search criteria"). The search criteria is optional, and is like the WHERE clause(s) in a query but without the word "WHERE". So the first part of the expression in my example basically said "count all the [Passed Test?] fields in tblMyTable where the value of [Passed Test?] is True". The 2nd half of the expression says "count all the [Surname] fields in tblMyTable". And the forward slash "/" is the division operator. So the whole expression evaluates to "the value that goes in this box is the number derived from the first DCount expression divided by the number derived from the second DCount expression" or, put another way "= X/Y".

HTH...

Ken S.
 
Your helpfulness and patience is greatly appreciated.

Thank you!

Fallyhag :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top