Dcount With Multiple Criteria (1 Viewer)

muralidaran

New member
Local time
Today, 14:40
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:40
Joined
May 7, 2009
Messages
19,246
CountMsg = DCount("*", "[F_Tbl_Msg]", "[ToUserID]= ('" & [TempVars]![TempUser] & "' Or [ToUserID]='All') And IsNull(DateReceived)")
 

muralidaran

New member
Local time
Today, 14:40
Joined
Jan 18, 2012
Messages
7
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..
 

Mile-O

Back once again...
Local time
Today, 12:40
Joined
Dec 10, 2002
Messages
11,316
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

Top Bottom