error data type mismatch

G

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top