Using textbox value for DCount() #Error

Zc kaiva

New member
Local time
Today, 16:37
Joined
May 9, 2021
Messages
9
I have a textbox 'Text1' which stores date value entered as report parameter on my report. When u use it with dcount() as criteria it gives me #error. This is what i have.

=Nz(Dcount("[BusNo]","[qryBus]","[qryBus].[RegDate]=[Text1]"),0)

Can anyone help me find my mistake?
 
1. Dcount will never return null, so Nz() is not needed.
2. You don't need to reference the query in the criteria argument.
3. You need to escape out of the criteria string to insert the date from the form.
4. You must use escape characters around the date value in the criteria.

Check out this post with very similar issue:

 
=Dcount("[BusNo]","qryBus","[RegDate]=#" & txtBox & "#")
 
=Dcount("[BusNo]","qryBus","[RegDate]=#" & Format$([Text1], "mm\/dd\/yyyy") & "#")
 
=Dcount("[BusNo]","qryBus","[RegDate]=#" & Format$([Text1], "mm\/dd\/yyyy") & "#")

I tried it but it keeps givim 0 as count.
 
does [RegDate] has "time" element in it?
 

Users who are viewing this thread

Back
Top Bottom