error data type mismatch

E

edward keith

Hi,
can you tell me why I get a messege "data type mismatch in criteria
expression."
I have a form called frmClient with a button "btnShowClientInfo.
The button should open a report in preview that gives me Client information.
It is based on qryClients. Can you please tell be why I get this error.
thanks for your help, Edward Keith (See Below)

Private Sub btnPrintClient_Click()
On Error GoTo Err_btnPrintClient_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ClientID] = " & Me![ClientID]
stDocName = "rptClients"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Exit_btnPrintClient_Click:
Exit Sub

Err_btnPrintClient_Click:
MsgBox Err.Description
Resume Exit_btnPrintClient_Click

End Sub
 
S

Steve Conway

Hi Keith,

My guess would be ClientID is a text data type not numeric.
Change this line:
stLinkCriteria = "[ClientID] = " & Me![ClientID]
to:
stLinkCriteria = "[ClientID] = '" & Me![ClientID] & "'"

HTH
Steve C
 
E

edward keith

That was it, Thanks a lot!

Steve Conway said:
Hi Keith,

My guess would be ClientID is a text data type not numeric.
Change this line:
stLinkCriteria = "[ClientID] = " & Me![ClientID]
to:
stLinkCriteria = "[ClientID] = '" & Me![ClientID] & "'"

HTH
Steve C

edward keith said:
Hi,
can you tell me why I get a messege "data type mismatch in criteria
expression."
I have a form called frmClient with a button "btnShowClientInfo.
The button should open a report in preview that gives me Client
information.
It is based on qryClients. Can you please tell be why I get this error.
thanks for your help, Edward Keith (See Below)

Private Sub btnPrintClient_Click()
On Error GoTo Err_btnPrintClient_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ClientID] = " & Me![ClientID]
stDocName = "rptClients"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Exit_btnPrintClient_Click:
Exit Sub

Err_btnPrintClient_Click:
MsgBox Err.Description
Resume Exit_btnPrintClient_Click

End Sub
 
Top