DCount with True/False criteria

gstylianou

Registered User.
Local time
Today, 09:03
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")
 
Keep in mind that Only Access uses -1 for true. So I would write --

& " AND [Active] = True"

to avoid any future issues.
 
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.
 
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.
 
Oh ye of little faith:)

Sadly Access has numerous situations were it allows very sloppy processing in an effort to "save" the novice but being sloppy always has a price.
 

Users who are viewing this thread

Back
Top Bottom