DCount with True/False criteria

gstylianou

Registered User.
Local time
Today, 23:08
Joined
Dec 16, 2013
Messages
359
Hi,

Just a question, How can I write correct the following function below to count only the records which the field [Active]=True?

a = DCount("[Patient_id]", "Patient Diseases", "[Patient_id] =" & Forms!MainForm.LogCustID)
 
a = DCount("1", "Patient Diseases", "Patient_ID = " & Forms!MainForm.LogCustID & " And [Active] = -1")
 
Also...
Code:
a = -DSum("Active", "Patient Diseases", "[Patient_id] =" & Forms!MainForm.LogCustID)
 
Access treats anything <> 0 as true. That doesn't necessarily apply to any other RDBMS though. SQL Server uses 1 as True so if you ever might need to upsize, use True when checking for the true value and leave the details to the RDBMS to sort out.
Thank you Pat.
I did a quick test this mornng to see that was actually the case.
 

Users who are viewing this thread

Back
Top Bottom