-----Original Message-----
Comments inline below
--
Marsh
MVP [MS Access]
Thanks, Marshall. I understand and tried what you
suggested and have 2 problems:
1. The MsgBox is too small - doesn't display all the
text, including the dates. How can I make the box
bigger?
The standard message box automatically expands to display
all of the text. Post your code (along with what you expect
the message's text to be) and maybe I'll be able to spot
something.
2. I tried the error handling. I have simple error
handling (see code) to display a message to tell me if
there is a problem. I tried to insert code for 2501, and
clearly haven't done that right. The user presses a
button and it runs ALL the weekly reports (5 right now) 3
of which could be empty. Can you tell me how to code the
error handling properly?
If (Me!grpReportList = 2) Then ' Weekly Reports
' Show Year, Qtr buttons (Qtrly)
EnableWeeklyButtons
stDocName = "rptPODetailsforWeek"
On Error GoTo PrintPOReports_Err
strStepErrorMsg = "Tell IT there was a
problem with Weekly PO Report"
DoCmd.OpenReport stDocName, acPreview
DoCmd.Maximize
stDocName = "rptSummaryWeek"
On Error GoTo PrintPOReports_Err
strStepErrorMsg = "Tell IT there was a
problem with Weekly PO Summary Report"
DoCmd.OpenReport stDocName, acPreview
DoCmd.Maximize
stDocName = "rptImpactofFreightChanges"
strStepErrorMsg = "Tell IT there was a problem with" & _
" Weekly Freight Report"
On Error Resume Next
DoCmd.OpenReport stDocName, acPreview
' Save the error number
ErrNum = Err.Number
' Restore your regular error handler
On Error GoTo PrintPOReports_Err
' Now check the error status
If ErrNum = 0 Then
' no error, carry on
ElseIf ErrNum <> 2501 Then ' Check for real error
' You can not use GoTo to get into
' your error handler
Err.Raise ErrNum
End If ' Note that 2501 just goes onto next report
stDocName = "rptPOCancelsbyDates"
On Error GoTo PrintPOReports_Err
strStepErrorMsg = "Tell IT there was a
problem with Weekly Cancels Report"
DoCmd.OpenReport stDocName, acPreview
DoCmd.Maximize
End If
This way of handling errors may be a little convoluted, but
I can't tell if there might be a better way without knowing
what you do with other possible errors. It may be better to
move your existing error logic to a Function procedure so
you don't have to do all the checks so many times.
.