J
jhmosow
I have a report with the following code:
Private Sub Report_Open(Cancel As Integer)
Dim DB_Version As Variant
Dim DocName As String
Dim LinkCriteria As String
On Error Resume Next
DB_Version = DLookup("OptionValue", "Option", "OptionName =
'DefaultDatabaseLevel'")
DB_Version = InputBox("Enter database level", , DB_Version)
If IsEmpty(DB_Version) = "" Or Len(DB_Version) = 0 Then
MsgBox "Cancel pressed"
DoCmd.Close acReport, "Product Listing By Database", acSaveNo
DocName = "Inquiries/Reports Menu"
DoCmd.OpenForm DocName, , , LinkCriteria
Exit Sub
End If
Me.ServerFilter = "Database_Version = " & DB_Version
DoCmd.RunMacro "ReportToolbarShow"
End Sub
What is happening is when Cancel is pressed in the Inputbox, this does
get trapped and processes the If statement. But the DoCmd.Close does
not close the report. If Cancel is selected in the Inputbox, I want to
stop all processing of this report and go back to my menu. Any idea
what I am doing wrong or how to code this? I am using Access 2003 and
this is an ADP.
TIA
Private Sub Report_Open(Cancel As Integer)
Dim DB_Version As Variant
Dim DocName As String
Dim LinkCriteria As String
On Error Resume Next
DB_Version = DLookup("OptionValue", "Option", "OptionName =
'DefaultDatabaseLevel'")
DB_Version = InputBox("Enter database level", , DB_Version)
If IsEmpty(DB_Version) = "" Or Len(DB_Version) = 0 Then
MsgBox "Cancel pressed"
DoCmd.Close acReport, "Product Listing By Database", acSaveNo
DocName = "Inquiries/Reports Menu"
DoCmd.OpenForm DocName, , , LinkCriteria
Exit Sub
End If
Me.ServerFilter = "Database_Version = " & DB_Version
DoCmd.RunMacro "ReportToolbarShow"
End Sub
What is happening is when Cancel is pressed in the Inputbox, this does
get trapped and processes the If statement. But the DoCmd.Close does
not close the report. If Cancel is selected in the Inputbox, I want to
stop all processing of this report and go back to my menu. Any idea
what I am doing wrong or how to code this? I am using Access 2003 and
this is an ADP.
TIA