A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

report with query parameter and no data



 
 
Thread Tools Display Modes
  #1  
Old August 3rd, 2009, 11:04 PM posted to microsoft.public.access.reports
JohnE
external usenet poster
 
Posts: 75
Default 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  
Old August 3rd, 2009, 11:18 PM posted to microsoft.public.access.reports
Clifford Bass[_2_]
external usenet poster
 
Posts: 1,295
Default 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  
Old August 3rd, 2009, 11:32 PM posted to microsoft.public.access.reports
JohnE
external usenet poster
 
Posts: 75
Default 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  
Old August 3rd, 2009, 11:44 PM posted to microsoft.public.access.reports
Clifford Bass[_2_]
external usenet poster
 
Posts: 1,295
Default report with query parameter and no data

Hi John,

You are welcome.

Clifford Bass

"JohnE" wrote:

Thanks. It worked.
... John

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.