View Full Version : Trouble with criteria expression


snorf3
08-03-2001, 02:50 PM
I'm trying to create a command button on my form that opens a corresponding report. My problem is that I have a "data type mismatch in criteria expression."

My code is this:

DoCmd.OpenReport stDocName, acPreview, , "[ClinicalID]='" & Me![ClinicalID] & "'"

The field I am using as the criteria, [ClinicalID], is an autonumber field. However, the way I have the code, I think access interprets it as text and thus the mismatch error.

Does anyone know how to change my where statement so that it specifies [ClinicalID] as autonumber and not text data type?

Thanks in advance for all help!

JGillespie
08-03-2001, 03:02 PM
Lose the quotes round the criteria:

DoCmd.OpenReport stDocName, acPreview, , "[ClinicalID]=" & Me![ClinicalID]

and you should have it. You do not need quotes if the criteria is a numeric value.

snorf3
08-07-2001, 09:27 AM
Thanks! That works beautifully.