Reputation: 3
I have a MS Access solution with the following code:
Private Sub Command1_Click()
Dim myrs As Recordset
Dim myPDF, myStmt As String
'Open a record set with a list of
' invoice number to print
myStmt = " Select distinct respon from
users"
Set myrs =
CurrentDb.OpenRecordset(myStmt)
' For each invoice print in a .PDF
Do until myrs.EOF
' Set the current path of your PDF file
' invoice
myPDF = "\\Share1\\*" & Format(myrs.Fields("respon"), "00000") & ".PDF"
' Open the report with the proper where condition
DoCmd.OpenReport "Printing OT", acViewPreview, ,"respon = " & myrs.Fields("respon").Value
...
...
I have 2 tables involved, one in MS Access and another in SQL Server, both with a field named "respon" as text datatype in both tables.
When the "DoCmd.OpenReport" is executed I get the error:
Access update error 3464 Data Type Mismatch
I don't know why.
Upvotes: 0
Views: 75
Reputation: 23837
To expand what I said in my comment, if the respon data type is string (text is string) then you need to add quotes around it:
DoCmd.OpenReport "Printing OT", acViewPreview, ,"respon = '" & myrs.Fields("respon").Value & "'"
Upvotes: 1