Hello Everyone,
I have run into a problem and I cant quite figure a way around It.
I have created a form which has a listbox which contains a list of reports. The listbox refers to a table for the report names.
I then have a Print Preview button which then looks to see if the Listbox is visible and if "Yes" it then previews the report. On the On Click event of the preview button I have the follwowing:
[Blue]Private Sub Preview_Click()
DoCmd.RunMacro "minimize"
If [lstreport1].Visible = True Then
DoCmd.OpenReport lstreport1.Column(0), acPreview
[lstreport1].Visible = False
ElseIf Me.[lstreport2].Visible = True Then
DoCmd.OpenReport lstreport2.Column(0), acPreview
[lstreport2].Visible = False
Else
End If
End Sub[/Blue]
If the report contains data it will open and everything is fine, but if there is no data then then I run into an error. The Reports properties are setup as follows.
The OnOpen event contains an event procedure which basically hides the database: [blue]DoCmd.RunMacro "mcrRestore" [/blue]
On the "On No Data" Event procedure there is:
[blue]MsgBox "There is no data for for the Builder Report during this period"
Cancel = True [/blue]
The error occurs when I click the preview button-I then receive the message "There is no data for for the Builder Report during this period". (Which is fine) I then receive the VB error "The OpenReport was cancelled" and when I look at the debug window it refers to:
[Blue]Private Sub Preview_Click()
DoCmd.RunMacro "minimize"
If [lstreport1].Visible = True Then
[red]DoCmd.OpenReport lstreport1.Column(0), acPreview
[lstreport1].Visible = False[/red]
ElseIf Me.[lstreport2].Visible = True Then
DoCmd.OpenReport lstreport2.Column(0), acPreview
[lstreport2].Visible = False
Else
End If
End Sub
How can I resolve this issue?
I have run into a problem and I cant quite figure a way around It.
I have created a form which has a listbox which contains a list of reports. The listbox refers to a table for the report names.
I then have a Print Preview button which then looks to see if the Listbox is visible and if "Yes" it then previews the report. On the On Click event of the preview button I have the follwowing:
[Blue]Private Sub Preview_Click()
DoCmd.RunMacro "minimize"
If [lstreport1].Visible = True Then
DoCmd.OpenReport lstreport1.Column(0), acPreview
[lstreport1].Visible = False
ElseIf Me.[lstreport2].Visible = True Then
DoCmd.OpenReport lstreport2.Column(0), acPreview
[lstreport2].Visible = False
Else
End If
End Sub[/Blue]
If the report contains data it will open and everything is fine, but if there is no data then then I run into an error. The Reports properties are setup as follows.
The OnOpen event contains an event procedure which basically hides the database: [blue]DoCmd.RunMacro "mcrRestore" [/blue]
On the "On No Data" Event procedure there is:
[blue]MsgBox "There is no data for for the Builder Report during this period"
Cancel = True [/blue]
The error occurs when I click the preview button-I then receive the message "There is no data for for the Builder Report during this period". (Which is fine) I then receive the VB error "The OpenReport was cancelled" and when I look at the debug window it refers to:
[Blue]Private Sub Preview_Click()
DoCmd.RunMacro "minimize"
If [lstreport1].Visible = True Then
[red]DoCmd.OpenReport lstreport1.Column(0), acPreview
[lstreport1].Visible = False[/red]
ElseIf Me.[lstreport2].Visible = True Then
DoCmd.OpenReport lstreport2.Column(0), acPreview
[lstreport2].Visible = False
Else
End If
End Sub
How can I resolve this issue?