I've used this same thing (just different object names) in another database to preview only the current record and it works fine.
In this database, however, when I click the cmd button, I get an error message of "Data type mismatch in criteria expression". My report is "Report2", my field is [Request #], & my form is CEARequest_form. Can you see anything?
The only thing different in this database is that the form has a subform, which was my original issue until I realized this wasn't even working. I have no idea !
Private Sub cmdPreviewReport_Click()
On Error GoTo Err_cmdPreviewReport_Click
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
DoCmd.RunCommand acCmdRefresh
DoCmd.OpenReport "Report2", acViewPreview, , "[Request #]=" & "'" & Forms!CEARequest_form![Request #] & "'"
Exit_cmdPreviewReport_Click:
Exit Sub
Err_cmdPreviewReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewReport_Click
End Sub
Thanks for any help or just confirm that I am crazy.
In this database, however, when I click the cmd button, I get an error message of "Data type mismatch in criteria expression". My report is "Report2", my field is [Request #], & my form is CEARequest_form. Can you see anything?
The only thing different in this database is that the form has a subform, which was my original issue until I realized this wasn't even working. I have no idea !
Private Sub cmdPreviewReport_Click()
On Error GoTo Err_cmdPreviewReport_Click
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
DoCmd.RunCommand acCmdRefresh
DoCmd.OpenReport "Report2", acViewPreview, , "[Request #]=" & "'" & Forms!CEARequest_form![Request #] & "'"
Exit_cmdPreviewReport_Click:
Exit Sub
Err_cmdPreviewReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewReport_Click
End Sub
Thanks for any help or just confirm that I am crazy.