I have a Report that is designed to respond to a form so I have put a bit of VBA code on the "On Open" property of the form. What I *want* to happen is that a message box appears telling the user that the report is reliant upon the form and give them the option of opening the form.
What I have is:
Private Sub Report_Open(Cancel As Integer)
' Don't open report if MembersDialogBox form isn't loaded.
If Not (IsLoaded("frmSetDate")) Then
Cancel = True
MsgBox "To preview or print this report, you must open " & "frmSelectJoinDate in Form view. Do you wish to open this form?", vbOKCancel, "Must Open Selection form"
If vbOk Then
DoCmd.Close "Listing by Membership Type"
DoCmd.OpenForm "frmSetDate"
Else
DoCmd.Close "Listing by Membership Type"
End If
Exit Sub
End If
End Sub
It brings up the message box, but when you click Ok, it gives the error message "Run-time error 13, Data type mismatch". What am I doing wrong?
Thanks
Catt
What I have is:
Private Sub Report_Open(Cancel As Integer)
' Don't open report if MembersDialogBox form isn't loaded.
If Not (IsLoaded("frmSetDate")) Then
Cancel = True
MsgBox "To preview or print this report, you must open " & "frmSelectJoinDate in Form view. Do you wish to open this form?", vbOKCancel, "Must Open Selection form"
If vbOk Then
DoCmd.Close "Listing by Membership Type"
DoCmd.OpenForm "frmSetDate"
Else
DoCmd.Close "Listing by Membership Type"
End If
Exit Sub
End If
End Sub
It brings up the message box, but when you click Ok, it gives the error message "Run-time error 13, Data type mismatch". What am I doing wrong?
Thanks
Catt