DCount error .... help!!

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

Hi guys,
I just can't seem to get the following Domain aggregate
function to work......I'm forever tripping over syntax
erros with these. It's now telling me I have a datatype
mismatch error which is presumably due to the Date but I
don't seem to know how to express it. Here's my current
attempt (which is obviously wrong!):

DCount
("[InspectionDate]", "tbl_InspectionReports", "CentreNo="
& Me.cboCentreNumber And "InspectionDate= " &
Me.txtInspectionDate) > 0

Can you help with this?

TIA

Lee
 
Hi Lee,

It looks like you may have a few problems with your
criteria string. The "And" should be inside the quotes,
and I believe the date needs to be surrounded by "#"
signs. Try the following to see if it will work:

DCount
("[InspectionDate]", "tbl_InspectionReports", "CentreNo
= " & Me.cboCentreNumber & " And InspectionDate = #" &
Me.txtInspectionDate & "#") > 0

Note, the >0 part is not part of the DCount() expression,
I assume that this was left over from a criteria
condition.

HTH

-Ted Allen
-----Original Message-----
Hi guys,
I just can't seem to get the following Domain aggregate
function to work......I'm forever tripping over syntax
erros with these. It's now telling me I have a datatype
mismatch error which is presumably due to the Date but I
don't seem to know how to express it. Here's my current
attempt (which is obviously wrong!):

DCount
("[InspectionDate]", "tbl_InspectionReports", "CentreNo="
 
Dates must be delimited with #. Also you were missing an & between
cboCentreNumber and AND. So...
DCount
("[InspectionDate]", "tbl_InspectionReports", "CentreNo="
& Me.cboCentreNumber & "And InspectionDate= #" &
Me.txtInspectionDate & "#") > 0
 
That's excellent!

Thanks for your help. I'll make a note for future
reference.

Lee

-----Original Message-----
Dates must be delimited with #. Also you were missing an & between
cboCentreNumber and AND. So...
DCount
("[InspectionDate]", "tbl_InspectionReports", "CentreNo="
& Me.cboCentreNumber & "And InspectionDate= #" &
Me.txtInspectionDate & "#") > 0

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org


Hi guys,
I just can't seem to get the following Domain aggregate
function to work......I'm forever tripping over syntax
erros with these. It's now telling me I have a datatype
mismatch error which is presumably due to the Date but I
don't seem to know how to express it. Here's my current
attempt (which is obviously wrong!):

DCount
("[InspectionDate]", "tbl_InspectionReports", "CentreNo="
& Me.cboCentreNumber And "InspectionDate= " &
Me.txtInspectionDate) > 0

Can you help with this?

TIA

Lee


.
 
Back
Top