W
Wayne Livingstone
I have a button on my form that is supposed to open a
report showing data relating to the currently displayed
record in the form. I have the following code on the On
Cleck event of the button:
Private Sub PreviewPrintReq_Click()
On Error GoTo PreviewPrintReq_Err
Dim strSqlSelect As String
Dim strSqlWhere As String
Dim strSqlExpr As String
strSqlSelect = "SELECT PrintReqID " & _
"FROM [Print_Requisition] "
strSqlWhere = " WHERE [Print_Requisition].PrintReqID =" _
& Chr$(34) &
[Forms]![PrintRequisition]![PrintReqID] & Chr$(34)
strSqlExpr = strSqlSelect & strSqlWhere & ";"
If IsNull(Me![PrintReqID]) Then
MsgBox "Enter printing data before previewing the
Printing Requisition report."
Else
DoCmd.OpenReport "PrintRequisition Report",
acPreview, , strSqlExpr
End If
PreviewPrintReq_Exit:
Exit Sub
PreviewPrintReq_Err:
MsgBox Err.Description
Resume PreviewPrintReq_Exit
End Sub
I get the error: Data type mismatch in criteria expression.
The report itself seems to work ok on its own and displays
data for all records.
report showing data relating to the currently displayed
record in the form. I have the following code on the On
Cleck event of the button:
Private Sub PreviewPrintReq_Click()
On Error GoTo PreviewPrintReq_Err
Dim strSqlSelect As String
Dim strSqlWhere As String
Dim strSqlExpr As String
strSqlSelect = "SELECT PrintReqID " & _
"FROM [Print_Requisition] "
strSqlWhere = " WHERE [Print_Requisition].PrintReqID =" _
& Chr$(34) &
[Forms]![PrintRequisition]![PrintReqID] & Chr$(34)
strSqlExpr = strSqlSelect & strSqlWhere & ";"
If IsNull(Me![PrintReqID]) Then
MsgBox "Enter printing data before previewing the
Printing Requisition report."
Else
DoCmd.OpenReport "PrintRequisition Report",
acPreview, , strSqlExpr
End If
PreviewPrintReq_Exit:
Exit Sub
PreviewPrintReq_Err:
MsgBox Err.Description
Resume PreviewPrintReq_Exit
End Sub
I get the error: Data type mismatch in criteria expression.
The report itself seems to work ok on its own and displays
data for all records.