Dcount With Multiple Criteria

muralidaran

New member
Local time
Today, 21:22
Joined
Jan 18, 2012
Messages
7
Hi Everyone...
Good day,
I have the below given Dcount code with multiple criteria and I wanted to add 1 more condition which I couldn't solve myself.
Kindly help me to fix this.

The Current Code
Code:
CountMsg = DCount("*", "[F_Tbl_Msg]", "[ToUserID]='" & [TempVars]![TempUser] & "' And IsNull(DateReceived)")

The Changed code.
Code:
CountMsg = DCount("*", "[F_Tbl_Msg]", "[ToUserID]='" & [TempVars]![TempUser] & "' Or "[ToUserID]='" & All & "' And IsNull(DateReceived)")

Please note that this post is already posted in Utter Access but I am not allowed to post the link here due to limitation.

Thanks

Best Regards
M.
 
CountMsg = DCount("*", "[F_Tbl_Msg]", "[ToUserID]= ('" & [TempVars]![TempUser] & "' Or [ToUserID]='All') And IsNull(DateReceived)")
 
Hi Mr. arnelgp
Thanks for your time and suggestion, I got an Run-Time error '3464', Data type mismatch in criteria expression.

The field ToUserID is a text field.

Please advise..
 
I would have thought IsNull(DateReceived) would be better written as DateReceived Is Null in this context.

Anyway,

Code:
CountMsg = DCount("*", "[F_Tbl_Msg]", "([ToUserID]= """ & [TempVars]![TempUser] & """ Or [ToUserID] = ""All"") And [DateReceived] Is Null")

Personally, I'd do away with all underscores, hyphens, whatever in your field/table/object names as it's universal pain when working in Access.
 

Users who are viewing this thread

Back
Top Bottom