Make text box display query count result

gerryp

Registered User.
Local time
Today, 14:45
Joined
May 10, 2007
Messages
32
I have a form bound to a table that contains many yes/no fields.
I have a "count" query that returns the correct amount of "yes's" and I want to display this amount in a text box.

The query is;
SELECT Count("") AS Expr1
FROM [Patient Info]
GROUP BY [Patient Info].ReferredToChildFamilyAgency
HAVING ((([Patient Info].ReferredToChildFamilyAgency)="yes"));


Any ideas?
 
Set this as the Control Source of the Textbox.
Code:
= DCount("*", "[Patient Info]", "ReferredToChildFamilyAgency = True")
The above is based on the information that the Field is set to Yes/No type.
 
Set this as the Control Source of the Textbox.
Code:
= DCount("*", "[Patient Info]", "ReferredToChildFamilyAgency = True")
The above is based on the information that the Field is set to Yes/No type.

Thanks Paul for the above.

I've entered 3 records in total, the code above should return 2 records out of 3 that are = Yes (as the query does) , but it returns 3 ??
 
Okay go to the design view of the table and see what is the exact data type of the field you are using. If you are using text type then try this.
Code:
= DCount("*", "[Patient Info]", "ReferredToChildFamilyAgency = 'Yes'")
 
Paul - that code is now working - really really appreciate your help - Cheers.
 
You're welcome ! Note for next time. We know only what you tell us, so please make sure you give the exact information to resolve your issue at the earliest. Good Luck.
 

Users who are viewing this thread

Back
Top Bottom