Trouble with criteria expression (1 Viewer)

snorf3

Registered User.
Local time
Today, 10:34
Joined
May 25, 2001
Messages
45
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!
 
J

JGillespie

Guest
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

Registered User.
Local time
Today, 10:34
Joined
May 25, 2001
Messages
45
Thanks! That works beautifully.
 

Users who are viewing this thread

Top Bottom