If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
report with query parameter and no data
I have a form that has a list box on it that lists all the reports. There is
a preview button on the form to preview the selected report. When the preview button is used, that is when the parameter input is requested. It all works fine so long as there is data to show. If there isn't any data, I get the no data message then an error message coming from the code behind the preview button. The code is below. Private Sub btnReportsListingPreview_Click() On Error GoTo btnReportsListingPreview_Click_Error If Not IsNull(Me.lstReports) Then DoCmd.OpenReport Me.lstReports, acViewPreview DoCmd.RunCommand acCmdFitToWindow End If On Error GoTo 0 Exit Sub btnReportsListingPreview_Click_Error: MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure btnReportsListingPreview_Click of VBA Document Form_frmReportModule" End Sub What can I do to prevent this error message from occurring? Is there more to add to the above? Thanks... John |
#2
|
|||
|
|||
report with query parameter and no data
Hi John,
Just check in the error handler for that particular error number. Note that you may get several different error numbers depending on what happens (no data, user cancels parameter box, some other possible action?): btnReportsListingPreview_Click_Error: If Err.Number 1234 And Err.Number 2345 Then MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure btnReportsListingPreview_Click of VBA Document Form_frmReportModule" End If End Sub Clifford Bass "JohnE" wrote: I have a form that has a list box on it that lists all the reports. There is a preview button on the form to preview the selected report. When the preview button is used, that is when the parameter input is requested. It all works fine so long as there is data to show. If there isn't any data, I get the no data message then an error message coming from the code behind the preview button. The code is below. Private Sub btnReportsListingPreview_Click() On Error GoTo btnReportsListingPreview_Click_Error If Not IsNull(Me.lstReports) Then DoCmd.OpenReport Me.lstReports, acViewPreview DoCmd.RunCommand acCmdFitToWindow End If On Error GoTo 0 Exit Sub btnReportsListingPreview_Click_Error: MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure btnReportsListingPreview_Click of VBA Document Form_frmReportModule" End Sub What can I do to prevent this error message from occurring? Is there more to add to the above? Thanks... John |
#3
|
|||
|
|||
report with query parameter and no data
Thanks. It worked.
.... John "Clifford Bass" wrote: Hi John, Just check in the error handler for that particular error number. Note that you may get several different error numbers depending on what happens (no data, user cancels parameter box, some other possible action?): btnReportsListingPreview_Click_Error: If Err.Number 1234 And Err.Number 2345 Then MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure btnReportsListingPreview_Click of VBA Document Form_frmReportModule" End If End Sub Clifford Bass "JohnE" wrote: I have a form that has a list box on it that lists all the reports. There is a preview button on the form to preview the selected report. When the preview button is used, that is when the parameter input is requested. It all works fine so long as there is data to show. If there isn't any data, I get the no data message then an error message coming from the code behind the preview button. The code is below. Private Sub btnReportsListingPreview_Click() On Error GoTo btnReportsListingPreview_Click_Error If Not IsNull(Me.lstReports) Then DoCmd.OpenReport Me.lstReports, acViewPreview DoCmd.RunCommand acCmdFitToWindow End If On Error GoTo 0 Exit Sub btnReportsListingPreview_Click_Error: MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure btnReportsListingPreview_Click of VBA Document Form_frmReportModule" End Sub What can I do to prevent this error message from occurring? Is there more to add to the above? Thanks... John |
#4
|
|||
|
|||
report with query parameter and no data
Hi John,
You are welcome. Clifford Bass "JohnE" wrote: Thanks. It worked. ... John |
Thread Tools | |
Display Modes | |
|
|