Empty report dilemma

  • Thread starter Thread starter Bette
  • Start date Start date
B

Bette

Any help is greatly appreciated.

The code below works fine to run a report given date
range input. I use it on a lot of reports. The problem is
I would like to suppress the report when there is no
data, which now displays error. It works fine, its just
not "clean".

How do I prevent a report when its empty and give the
user a "no data" message?

Thanks,
Bette

This is a command button on an unbound form that opens a
form for date input.
It assigns a code number for the report [rpt0 Cancels].
The report is run for the dates input here.

Private Sub btnCancelsSummary_Click()
On Error GoTo err_btnCancelsSummary_Click

DoCmd.OpenForm "frm0 GetDates"
forms![frm0 GetDates].FormNum = 81
Me.Visible = False

exit_btnCancelsSummary_Click:
Exit Sub
err_btnCancelsSummary_Click:
MsgBox Err.Description
Resume exit_btnCancelsSummary_Click
End Sub


This is a command button on [frm0 GetDates] that accepts
the report's date range as input.
If//EndIf statement repeats for all reports that uses
[frm0 GetDates] for date range input.


Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
MsgBox Err.Description
Resume Exit_btnAcceptDates_Click

End Sub
 
Bette,

In the Report's OnNoData event, write:

MsgBox "No records in this time period."
Cancel = True

In the Command Button's click event, add some error handling
to trap for error 2501 which occurs if you cancel the report:

Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
If Err = 2501 Then
Else
MsgBox Err.Description
End If
Resume Exit_btnAcceptDates_Click

End Sub
 
1) See what happens if you code the Report's Close event:
Forms![frm0 GetDates].Visible = True

Run the report. Is it OK Now?

If not..

2) Comment out the new error handling that trapped error 2501.

Re-enter your original error handling.
It should look like your original code:

Err_btnAcceptDates_Click:
MsgBox Err.Description
Resume Exit_btnAcceptDates_Click

Run the report.
You should get the "No records" message and the report cancels.
Do you get an additional message that "You canceled the report', etc.?

If so, un-comment the error handling that traps error 2501,
and comment out your original error handling.
Place a code break on the
If Err = 2501 Then
line. Run the report again.
Step through the code line by line after the code stops.

You're probably hung up on the Resume Exit_btnAcceptDates_Click.
See where the processing goes after that line.

You may have to trap error 2501 further back (in a Switchboard, perhaps).

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Bette said:
Thanks Fredg. The form is suppressed, the message
displays, but the unbound form (or something else) hangs
at the conclusion. I must use Task Manager to abandon and
recover.

Any thoughts what might be the culprit?

Thanks, Bette.
-----Original Message-----
Bette,

In the Report's OnNoData event, write:

MsgBox "No records in this time period."
Cancel = True

In the Command Button's click event, add some error handling
to trap for error 2501 which occurs if you cancel the report:

Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
If Err = 2501 Then
Else
MsgBox Err.Description
End If
Resume Exit_btnAcceptDates_Click

End Sub

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Bette said:
Any help is greatly appreciated.

The code below works fine to run a report given date
range input. I use it on a lot of reports. The problem is
I would like to suppress the report when there is no
data, which now displays error. It works fine, its just
not "clean".

How do I prevent a report when its empty and give the
user a "no data" message?

Thanks,
Bette

This is a command button on an unbound form that opens a
form for date input.
It assigns a code number for the report [rpt0 Cancels].
The report is run for the dates input here.

Private Sub btnCancelsSummary_Click()
On Error GoTo err_btnCancelsSummary_Click

DoCmd.OpenForm "frm0 GetDates"
forms![frm0 GetDates].FormNum = 81
Me.Visible = False

exit_btnCancelsSummary_Click:
Exit Sub
err_btnCancelsSummary_Click:
MsgBox Err.Description
Resume exit_btnCancelsSummary_Click
End Sub


This is a command button on [frm0 GetDates] that accepts
the report's date range as input.
If//EndIf statement repeats for all reports that uses
[frm0 GetDates] for date range input.


Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
MsgBox Err.Description
Resume Exit_btnAcceptDates_Click

End Sub


.
 
Thanks again Fred...I think, I hope I figured it out with
your help. At the close of preview I was making the form
with the button that called the report visible again.
When I changed that to my GetDates form it works.
However, my main form behind the GetDates popup form is
not maximized when I make GetDates visible that way.

How do I get is max'd again?

Thanks, Bette.
-----Original Message-----
1) See what happens if you code the Report's Close event:
Forms![frm0 GetDates].Visible = True

Run the report. Is it OK Now?

If not..

2) Comment out the new error handling that trapped error 2501.

Re-enter your original error handling.
It should look like your original code:

Err_btnAcceptDates_Click:
MsgBox Err.Description
Resume Exit_btnAcceptDates_Click

Run the report.
You should get the "No records" message and the report cancels.
Do you get an additional message that "You canceled the report', etc.?

If so, un-comment the error handling that traps error 2501,
and comment out your original error handling.
Place a code break on the
If Err = 2501 Then
line. Run the report again.
Step through the code line by line after the code stops.

You're probably hung up on the Resume Exit_btnAcceptDates_Click.
See where the processing goes after that line.

You may have to trap error 2501 further back (in a Switchboard, perhaps).

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Bette said:
Thanks Fredg. The form is suppressed, the message
displays, but the unbound form (or something else) hangs
at the conclusion. I must use Task Manager to abandon and
recover.

Any thoughts what might be the culprit?

Thanks, Bette.
-----Original Message-----
Bette,

In the Report's OnNoData event, write:

MsgBox "No records in this time period."
Cancel = True

In the Command Button's click event, add some error handling
to trap for error 2501 which occurs if you cancel the report:

Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
If Err = 2501 Then
Else
MsgBox Err.Description
End If
Resume Exit_btnAcceptDates_Click

End Sub

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Any help is greatly appreciated.

The code below works fine to run a report given date
range input. I use it on a lot of reports. The
problem
is
I would like to suppress the report when there is no
data, which now displays error. It works fine, its just
not "clean".

How do I prevent a report when its empty and give the
user a "no data" message?

Thanks,
Bette

This is a command button on an unbound form that
opens
a
form for date input.
It assigns a code number for the report [rpt0 Cancels].
The report is run for the dates input here.

Private Sub btnCancelsSummary_Click()
On Error GoTo err_btnCancelsSummary_Click

DoCmd.OpenForm "frm0 GetDates"
forms![frm0 GetDates].FormNum = 81
Me.Visible = False

exit_btnCancelsSummary_Click:
Exit Sub
err_btnCancelsSummary_Click:
MsgBox Err.Description
Resume exit_btnCancelsSummary_Click
End Sub


This is a command button on [frm0 GetDates] that accepts
the report's date range as input.
If//EndIf statement repeats for all reports that uses
[frm0 GetDates] for date range input.


Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
MsgBox Err.Description
Resume Exit_btnAcceptDates_Click

End Sub


.


.
 
If you are closing the form the
simplest way to get it maximized is to place:
DoCmd.Maximize
in the Switchboard Open event.

However, since it is staying open but hidden, use the form's Current event.
It will always be maximized.

Be aware that this will in turn maximize all forms/reports, etc.
If you wish something not maximized, write:
DoCmd.Restore
in the Open event of that form or report.

Try it out before you do (restore) however, as forms opened in
Dialog are not maximized, and you may not need to restore.

See Access help on Maximize and Restore.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Bette said:
Thanks again Fred...I think, I hope I figured it out with
your help. At the close of preview I was making the form
with the button that called the report visible again.
When I changed that to my GetDates form it works.
However, my main form behind the GetDates popup form is
not maximized when I make GetDates visible that way.

How do I get is max'd again?

Thanks, Bette.
-----Original Message-----
1) See what happens if you code the Report's Close event:
Forms![frm0 GetDates].Visible = True

Run the report. Is it OK Now?

If not..

2) Comment out the new error handling that trapped error 2501.

Re-enter your original error handling.
It should look like your original code:

Err_btnAcceptDates_Click:
MsgBox Err.Description
Resume Exit_btnAcceptDates_Click

Run the report.
You should get the "No records" message and the report cancels.
Do you get an additional message that "You canceled the report', etc.?

If so, un-comment the error handling that traps error 2501,
and comment out your original error handling.
Place a code break on the
If Err = 2501 Then
line. Run the report again.
Step through the code line by line after the code stops.

You're probably hung up on the Resume Exit_btnAcceptDates_Click.
See where the processing goes after that line.

You may have to trap error 2501 further back (in a Switchboard, perhaps).

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Bette said:
Thanks Fredg. The form is suppressed, the message
displays, but the unbound form (or something else) hangs
at the conclusion. I must use Task Manager to abandon and
recover.

Any thoughts what might be the culprit?

Thanks, Bette.
-----Original Message-----
Bette,

In the Report's OnNoData event, write:

MsgBox "No records in this time period."
Cancel = True

In the Command Button's click event, add some error
handling
to trap for error 2501 which occurs if you cancel the
report:

Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
If Err = 2501 Then
Else
MsgBox Err.Description
End If
Resume Exit_btnAcceptDates_Click

End Sub

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Any help is greatly appreciated.

The code below works fine to run a report given date
range input. I use it on a lot of reports. The problem
is
I would like to suppress the report when there is no
data, which now displays error. It works fine, its just
not "clean".

How do I prevent a report when its empty and give the
user a "no data" message?

Thanks,
Bette

This is a command button on an unbound form that opens
a
form for date input.
It assigns a code number for the report [rpt0 Cancels].
The report is run for the dates input here.

Private Sub btnCancelsSummary_Click()
On Error GoTo err_btnCancelsSummary_Click

DoCmd.OpenForm "frm0 GetDates"
forms![frm0 GetDates].FormNum = 81
Me.Visible = False

exit_btnCancelsSummary_Click:
Exit Sub
err_btnCancelsSummary_Click:
MsgBox Err.Description
Resume exit_btnCancelsSummary_Click
End Sub


This is a command button on [frm0 GetDates] that
accepts
the report's date range as input.
If//EndIf statement repeats for all reports that uses
[frm0 GetDates] for date range input.


Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
MsgBox Err.Description
Resume Exit_btnAcceptDates_Click

End Sub


.


.
 
I do use DoCmd.Max most everywhere...except popups I wish
to stay sized. The situation here is my main form is
maxed current and only this case causes it to not be
max'd.

What I want is the popup [GetDates] which has focus to
stay sized and the mainform behind in, not focus, but
visible to stay max'd. Something is UN-maxing it. I
cannot see what is doing it.

Other ideas?

Thanks, Bette

-----Original Message-----
If you are closing the form the
simplest way to get it maximized is to place:
DoCmd.Maximize
in the Switchboard Open event.

However, since it is staying open but hidden, use the form's Current event.
It will always be maximized.

Be aware that this will in turn maximize all forms/reports, etc.
If you wish something not maximized, write:
DoCmd.Restore
in the Open event of that form or report.

Try it out before you do (restore) however, as forms opened in
Dialog are not maximized, and you may not need to restore.

See Access help on Maximize and Restore.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Bette said:
Thanks again Fred...I think, I hope I figured it out with
your help. At the close of preview I was making the form
with the button that called the report visible again.
When I changed that to my GetDates form it works.
However, my main form behind the GetDates popup form is
not maximized when I make GetDates visible that way.

How do I get is max'd again?

Thanks, Bette.
-----Original Message-----
1) See what happens if you code the Report's Close event:
Forms![frm0 GetDates].Visible = True

Run the report. Is it OK Now?

If not..

2) Comment out the new error handling that trapped
error
2501.
Re-enter your original error handling.
It should look like your original code:

Err_btnAcceptDates_Click:
MsgBox Err.Description
Resume Exit_btnAcceptDates_Click

Run the report.
You should get the "No records" message and the report cancels.
Do you get an additional message that "You canceled
the
report', etc.?
If so, un-comment the error handling that traps error 2501,
and comment out your original error handling.
Place a code break on the
If Err = 2501 Then
line. Run the report again.
Step through the code line by line after the code stops.

You're probably hung up on the Resume Exit_btnAcceptDates_Click.
See where the processing goes after that line.

You may have to trap error 2501 further back (in a Switchboard, perhaps).

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Thanks Fredg. The form is suppressed, the message
displays, but the unbound form (or something else) hangs
at the conclusion. I must use Task Manager to
abandon
and
recover.

Any thoughts what might be the culprit?

Thanks, Bette.
-----Original Message-----
Bette,

In the Report's OnNoData event, write:

MsgBox "No records in this time period."
Cancel = True

In the Command Button's click event, add some error
handling
to trap for error 2501 which occurs if you cancel the
report:

Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
If Err = 2501 Then
Else
MsgBox Err.Description
End If
Resume Exit_btnAcceptDates_Click

End Sub

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Any help is greatly appreciated.

The code below works fine to run a report given date
range input. I use it on a lot of reports. The problem
is
I would like to suppress the report when there is no
data, which now displays error. It works fine,
its
just
not "clean".

How do I prevent a report when its empty and give the
user a "no data" message?

Thanks,
Bette

This is a command button on an unbound form that opens
a
form for date input.
It assigns a code number for the report [rpt0 Cancels].
The report is run for the dates input here.

Private Sub btnCancelsSummary_Click()
On Error GoTo err_btnCancelsSummary_Click

DoCmd.OpenForm "frm0 GetDates"
forms![frm0 GetDates].FormNum = 81
Me.Visible = False

exit_btnCancelsSummary_Click:
Exit Sub
err_btnCancelsSummary_Click:
MsgBox Err.Description
Resume exit_btnCancelsSummary_Click
End Sub


This is a command button on [frm0 GetDates] that
accepts
the report's date range as input.
If//EndIf statement repeats for all reports that uses
[frm0 GetDates] for date range input.


Private Sub btnAcceptDates_Click()
On Error GoTo Err_btnAcceptDates_Click
Dim stDocName As String

If Me.FormNum = 81 Then
stDocName = "rpt0 Cancels"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdFitToWindow
Me.Visible = False
End If

Exit_btnAcceptDates_Click:
Exit Sub

Err_btnAcceptDates_Click:
MsgBox Err.Description
Resume Exit_btnAcceptDates_Click

End Sub


.



.


.
 
Back
Top