PC Review


Reply
Thread Tools Rate Thread

Blank Report Message

 
 
Ann
Guest
Posts: n/a
 
      5th Feb 2010
I am working with Access 2002 trying to add code to a report when it opens to
tell the user when there aren't any records to display. It works fine on a
regular report, but I have a report that starts out blank, no query and no
fields, but has two subs on it. I needed to do this because of calculations
done in the footer on different fields. I have added the following code to
the button that opens the report, rptQuestionsOneAndFive.

Private Sub Command30_Click()
On Error GoTo ErrorOpen
DoCmd.OpenReport "rptCalendar", acViewPreview

ExitOpen:
Exit Sub

ErrorOpen:
If Err = 2501 Then
Resume ExitOpen
Else
MsgBox Err.Description
Resume ExitOpen
End If

End Sub

I then added the following code to both of the subreports, subrptQuestionOne
and subrptQuestionFive:

Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrorHandler
MsgBox "There are currently no records to display.", vbOKOnly
Cancel = True

ExitReport:
Exit Sub

ErrorHandler:
MsgBox Err.Description
Resume ExitReport

End Sub

All I get is a blank report since the subs are on a blank report. Is there
a way to still have the message appear if the report still opens but is
blank. I'm a beginner in VB so hopefully it won't be too complex if it can
be done. Thanks in advance for the help.
 
Reply With Quote
 
 
 
 
Ann
Guest
Posts: n/a
 
      5th Feb 2010
I have a typo from copying from a different report that works. The following
line should be:

DoCmd.OpenReport "rptQuestionsOneAndFive", acViewPreview

and not

DoCmd.OpenReport "rptCalendar", acViewPreview



"Ann" wrote:

> I am working with Access 2002 trying to add code to a report when it opens to
> tell the user when there aren't any records to display. It works fine on a
> regular report, but I have a report that starts out blank, no query and no
> fields, but has two subs on it. I needed to do this because of calculations
> done in the footer on different fields. I have added the following code to
> the button that opens the report, rptQuestionsOneAndFive.
>
> Private Sub Command30_Click()
> On Error GoTo ErrorOpen
> DoCmd.OpenReport "rptCalendar", acViewPreview
>
> ExitOpen:
> Exit Sub
>
> ErrorOpen:
> If Err = 2501 Then
> Resume ExitOpen
> Else
> MsgBox Err.Description
> Resume ExitOpen
> End If
>
> End Sub
>
> I then added the following code to both of the subreports, subrptQuestionOne
> and subrptQuestionFive:
>
> Private Sub Report_NoData(Cancel As Integer)
> On Error GoTo ErrorHandler
> MsgBox "There are currently no records to display.", vbOKOnly
> Cancel = True
>
> ExitReport:
> Exit Sub
>
> ErrorHandler:
> MsgBox Err.Description
> Resume ExitReport
>
> End Sub
>
> All I get is a blank report since the subs are on a blank report. Is there
> a way to still have the message appear if the report still opens but is
> blank. I'm a beginner in VB so hopefully it won't be too complex if it can
> be done. Thanks in advance for the help.

 
Reply With Quote
 
Ann
Guest
Posts: n/a
 
      5th Feb 2010

Thanks, but I don't need this anymore. I got it to work by redesigning the
report.
"Ann" wrote:

> I have a typo from copying from a different report that works. The following
> line should be:
>
> DoCmd.OpenReport "rptQuestionsOneAndFive", acViewPreview
>
> and not
>
> DoCmd.OpenReport "rptCalendar", acViewPreview
>
>
>
> "Ann" wrote:
>
> > I am working with Access 2002 trying to add code to a report when it opens to
> > tell the user when there aren't any records to display. It works fine on a
> > regular report, but I have a report that starts out blank, no query and no
> > fields, but has two subs on it. I needed to do this because of calculations
> > done in the footer on different fields. I have added the following code to
> > the button that opens the report, rptQuestionsOneAndFive.
> >
> > Private Sub Command30_Click()
> > On Error GoTo ErrorOpen
> > DoCmd.OpenReport "rptCalendar", acViewPreview
> >
> > ExitOpen:
> > Exit Sub
> >
> > ErrorOpen:
> > If Err = 2501 Then
> > Resume ExitOpen
> > Else
> > MsgBox Err.Description
> > Resume ExitOpen
> > End If
> >
> > End Sub
> >
> > I then added the following code to both of the subreports, subrptQuestionOne
> > and subrptQuestionFive:
> >
> > Private Sub Report_NoData(Cancel As Integer)
> > On Error GoTo ErrorHandler
> > MsgBox "There are currently no records to display.", vbOKOnly
> > Cancel = True
> >
> > ExitReport:
> > Exit Sub
> >
> > ErrorHandler:
> > MsgBox Err.Description
> > Resume ExitReport
> >
> > End Sub
> >
> > All I get is a blank report since the subs are on a blank report. Is there
> > a way to still have the message appear if the report still opens but is
> > blank. I'm a beginner in VB so hopefully it won't be too complex if it can
> > be done. Thanks in advance for the help.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If unbound list box in report is blank then don't show report deta Timmy Microsoft Access Reports 5 5th Nov 2008 08:47 PM
Printing a message on a blank page of a report Tony Williams Microsoft Access Reports 4 7th Jul 2006 09:21 AM
subreport in report footer has no data, showing blank page at the end of the report FA Microsoft Access Reports 1 16th May 2006 09:16 PM
blank line in a query for blank lines in a report Sandi Microsoft Access Queries 4 4th Jan 2006 08:12 PM
MessageBox coming up with blank message and blank buttons. =?Utf-8?B?TWlrZSBM?= Microsoft VB .NET 3 30th Jun 2005 11:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:47 AM.