Dcount with Multiple Conditions

Ksabai

Registered User.
Local time
Today, 11:01
Joined
Jul 31, 2017
Messages
104
Iam getting error with the following Line:

If DCount("[Duty]", "tblstaff", "[SellerID]= sSellerID And ([Duty] = 8 Or [Duty] = 12)") >= 1 Then
Also tried - If DCount("[Duty]", "tblstaff", "[SellerID]=" & sSellerID And "([Duty] = 8 Or [Duty] = 12)") >= 1 Then
sSellerID is an Integer

Can Someone help
 
if SellerID is string:

If DCount("[Duty]", "tblstaff", "[SellerID]= '" & sSellerID & "' And ([Duty] = 8 Or [Duty] = 12)") >= 1

or Numeric:

If DCount("[Duty]", "tblstaff", "[SellerID]= " & sSellerID & " And ([Duty] = 8 Or [Duty] = 12)") >= 1

also you can use Nz() function, in case tblStaff has no record yet, eg:

If Nz(DCount("[Duty]", "tblstaff", "[SellerID]= " & sSellerID & " And ([Duty] = 8 Or [Duty] = 12)"), 0) >= 1
 
If there are no records in table, DCount() will return 0 so Nz is not needed.
 
Yes isn't it interesting that DSum() and DMax() need the Nz() (to convert a Null to 0) but DCount() does not...
 
I think DCount() is the only domain aggregate that does not return Null.
 

Users who are viewing this thread

Back
Top Bottom