I have a report that runs fine with data. If there is no data, I have
its NO Data event sending a MsgBox and cancelling the report.
Then it seems I still get the 2501 message on the Open Report command,
even though I have the code to trap Err 2501 (from many postings - all
looked the same to me) on the button the user pressed to get the
report.
I never see the code going to my error handling on the button. If I
debug, I am in an endless loop with the No data message, followed by
the 2501 message. I suspect my problem is somewhere else - maybe with
the error handling?
Can anyone help? This is VERY frustrating!
Code below.
Thanks so much. I can't release this to the user with this error in it.
sara
[The name of the button is cmdPOReports]
Private Sub cmdPOReports_Cl ick()
On Error GoTo Err_cmdPOReport s_Click
' The user has chosen the frame with all the Pallet Reports
On Error GoTo Err_cmdPOReport s_Click
Dim strDocName As String ' Report as Variable to print
Dim strStepErrorMsg As String ' Description for Error
Dim dtmDate As Date ' Date for File Name
Dim strWhere As String ' Where clause for PO reports
Dim lngMerchantKey As Long
Dim lngDeptNum As Long
Dim strVendor As String
Dim dtmStartDate As Date
Dim dtmEndDate As Date
Dim strBetween As String ' Between dates string for
selection
' Find out what button was chosen, then print preview report for
that choice
Select Case Me.fraPOReports
Case 1 ' POs for a Merchant - Range
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtSt artDate) Then
MsgBox "Please enter the Starting Date for the reports", ,
"W5-Enter Report Date"
Me.txtStartDate .SetFocus
GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtEn dDate) Then
MsgBox "Please enter the Ending Date for the reports", ,
"W5-Enter Report Date"
Me.txtEndDate.S etFocus
GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate
dtmEndDate = Me.txtEndDate
strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate &
"#"
strWhere = " [SuggShipDate] " & strBetween
' If user selected "ALL", show ALL merchants in range
lngMerchantKey = Me.cboMerchant. Column(0)
If lngMerchantKey = 0 Then
strWhere = strWhere
Else
strWhere = "[MerchantKey] = " & lngMerchantKey & " And " &
strWhere
End If
strDocName = "rptPODetai ls"
strStepErrorMsg = "Tell IT there was a problem with Merchant POs"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere
DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
Case 2 ' PO Ship Date Range
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtSt artDate) Then
MsgBox "Please enter the Starting Date for the reports", ,
"W5-Enter Report Date"
Me.txtStartDate .SetFocus
GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtEn dDate) Then
MsgBox "Please enter the Ending Date for the reports", ,
"W5-Enter Report Date"
Me.txtEndDate.S etFocus
GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate
dtmEndDate = Me.txtEndDate
strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate &
"#"
strDocName = "rptPODetai ls"
strWhere = " [SuggShipDate] " & strBetween
strStepErrorMsg = "Tell IT there was a problem with Ship date Range
Rpt"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere
DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
......(There are cases 3-6, but they are nearly identical to the others,
so I deleted the code here to save boring space. If it's needed, I'll
post it)
End Select
Exit_cmdPORepor ts_Click:
Exit Sub
Err_cmdPOReport s_Click:
If Err = 2501 Then
Else
MsgBox "Contact Sara with the following informaiton " _
& Err.Nuumber & "" & Err.Description , , "W5 - Print PO
Reports"
Resume Exit_cmdPORepor ts_Click
End If
End Sub
[In rptPODetails] NO data and On Open
Private Sub Report_NoData(C ancel As Integer)
'Tell the user there is no data
MsgBox "There are no POs for this criteria "
Cancel = True
End Sub
Private Sub Report_Open(Can cel As Integer)
On Error GoTo Err_Report_Open
' Set Sorting and Grouping for this report
Dim strMerch As String
Select Case Forms.frmPrintR eports.fraPORep orts
Case 1
' Merchant Report Sort: Merch Last Name, PO Num, nothing
strMerch = Forms!frmPrintR eports.cboMerch ant.Column(1)
Me.GroupLevel(0 ).ControlSource = "MerchLastN ame"
Me.GroupLevel(1 ).ControlSource = "PONum"
Me.GroupLevel(2 ).ControlSource = "=1"
GoTo Exit_Report_Ope n
Case 2
' Sugg Ship Date Sort: Sugg Ship Date, PO Num, nothing
Me.GroupLevel(0 ).ControlSource = "SuggShipDa te"
Me.GroupLevel(1 ).ControlSource = "PONum"
Me.GroupLevel(2 ).ControlSource = "=1"
GoTo Exit_Report_Ope n
....(Again, there is code for cases 3-6; virtually identical - just
setting the sort order on the report)
End Select
Exit_Report_Ope n:
Exit Sub
Err_Report_Open :
MsgBox "Call Sara with the following information: Err Report Open"
_
& vbCrLf & Err.Number & " " & Err.Description , , "W5 - Error
Report Open Code"
GoTo Exit_Report_Ope n
End Sub
I even tried (based on a posting I saw):
Private Sub Report_Error(Da taErr As Integer, Response As Integer)
Exit Sub
End Sub 8 2444
sara wrote:
I have a report that runs fine with data. If there is no data, I have
its NO Data event sending a MsgBox and cancelling the report.
Then it seems I still get the 2501 message on the Open Report command,
even though I have the code to trap Err 2501 (from many postings - all
looked the same to me) on the button the user pressed to get the
report.
I never see the code going to my error handling on the button. If I
debug, I am in an endless loop with the No data message, followed by
the 2501 message. I suspect my problem is somewhere else - maybe with
the error handling?
Can anyone help? This is VERY frustrating!
Code below.
Thanks so much. I can't release this to the user with this error in it.
sara
[The name of the button is cmdPOReports]
Private Sub cmdPOReports_Cl ick()
On Error GoTo Err_cmdPOReport s_Click
' The user has chosen the frame with all the Pallet Reports
On Error GoTo Err_cmdPOReport s_Click
Dim strDocName As String ' Report as Variable to print
Dim strStepErrorMsg As String ' Description for Error
Dim dtmDate As Date ' Date for File Name
Dim strWhere As String ' Where clause for PO reports
Dim lngMerchantKey As Long
Dim lngDeptNum As Long
Dim strVendor As String
Dim dtmStartDate As Date
Dim dtmEndDate As Date
Dim strBetween As String ' Between dates string for
selection
' Find out what button was chosen, then print preview report for
that choice
Select Case Me.fraPOReports
Case 1 ' POs for a Merchant - Range
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtSt artDate) Then
MsgBox "Please enter the Starting Date for the reports", ,
"W5-Enter Report Date"
Me.txtStartDate .SetFocus
GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtEn dDate) Then
MsgBox "Please enter the Ending Date for the reports", ,
"W5-Enter Report Date"
Me.txtEndDate.S etFocus
GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate
dtmEndDate = Me.txtEndDate
strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate &
"#"
strWhere = " [SuggShipDate] " & strBetween
' If user selected "ALL", show ALL merchants in range
lngMerchantKey = Me.cboMerchant. Column(0)
If lngMerchantKey = 0 Then
strWhere = strWhere
Else
strWhere = "[MerchantKey] = " & lngMerchantKey & " And " &
strWhere
End If
strDocName = "rptPODetai ls"
strStepErrorMsg = "Tell IT there was a problem with Merchant POs"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere
DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
Case 2 ' PO Ship Date Range
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtSt artDate) Then
MsgBox "Please enter the Starting Date for the reports", ,
"W5-Enter Report Date"
Me.txtStartDate .SetFocus
GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtEn dDate) Then
MsgBox "Please enter the Ending Date for the reports", ,
"W5-Enter Report Date"
Me.txtEndDate.S etFocus
GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate
dtmEndDate = Me.txtEndDate
strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate &
"#"
strDocName = "rptPODetai ls"
strWhere = " [SuggShipDate] " & strBetween
strStepErrorMsg = "Tell IT there was a problem with Ship date Range
Rpt"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere
DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
.....(There are cases 3-6, but they are nearly identical to the others,
so I deleted the code here to save boring space. If it's needed, I'll
post it)
End Select
Exit_cmdPORepor ts_Click:
Exit Sub
Err_cmdPOReport s_Click:
If Err = 2501 Then
Else
MsgBox "Contact Sara with the following informaiton " _
& Err.Nuumber & "" & Err.Description , , "W5 - Print PO
Reports"
Resume Exit_cmdPORepor ts_Click
End If
End Sub
[In rptPODetails] NO data and On Open
Private Sub Report_NoData(C ancel As Integer)
'Tell the user there is no data
MsgBox "There are no POs for this criteria "
Cancel = True
End Sub
Private Sub Report_Open(Can cel As Integer)
On Error GoTo Err_Report_Open
' Set Sorting and Grouping for this report
Dim strMerch As String
Select Case Forms.frmPrintR eports.fraPORep orts
Case 1
' Merchant Report Sort: Merch Last Name, PO Num, nothing
strMerch = Forms!frmPrintR eports.cboMerch ant.Column(1)
Me.GroupLevel(0 ).ControlSource = "MerchLastN ame"
Me.GroupLevel(1 ).ControlSource = "PONum"
Me.GroupLevel(2 ).ControlSource = "=1"
GoTo Exit_Report_Ope n
Case 2
' Sugg Ship Date Sort: Sugg Ship Date, PO Num, nothing
Me.GroupLevel(0 ).ControlSource = "SuggShipDa te"
Me.GroupLevel(1 ).ControlSource = "PONum"
Me.GroupLevel(2 ).ControlSource = "=1"
GoTo Exit_Report_Ope n
...(Again, there is code for cases 3-6; virtually identical - just
setting the sort order on the report)
End Select
Exit_Report_Ope n:
Exit Sub
Err_Report_Open :
MsgBox "Call Sara with the following information: Err Report Open"
_
& vbCrLf & Err.Number & " " & Err.Description , , "W5 - Error
Report Open Code"
GoTo Exit_Report_Ope n
End Sub
I even tried (based on a posting I saw):
Private Sub Report_Error(Da taErr As Integer, Response As Integer)
Exit Sub
End Sub
Well, you could try this. Also, change the to "informatio n"
Err_cmdPOReport s_Click:
If Err <2501 Then
MsgBox "Contact Sara with the following informaiton " _
& Err.Nuumber & "" & Err.Description , ,_
"W5 - Print PO Reports"
End If
Resume Exit_cmdPORepor ts_Click
End Sub
You'll notice I moved the Resume out of the IF statement in the above
procedure.
Also, I'm not a great fan of GoTos...especia lly when Resume is normally
used. For example, I'd do this instead or using your GoTo.
Err_Report_Open :
MsgBox "Call Sara with the following information: Err Report Open"
Resume Exit_Report_Ope n
End Sub
This may not correct your problem, but it certainly won't hurt either.
Thanks, Salad (I'm still working on the other db - but this is for
work)
I tried this - along with the spelling correction - and I still get the
same error. Any other ideas?
thanks
Sara
salad wrote:
sara wrote:
I have a report that runs fine with data. If there is no data, I have
its NO Data event sending a MsgBox and cancelling the report.
Then it seems I still get the 2501 message on the Open Report command,
even though I have the code to trap Err 2501 (from many postings - all
looked the same to me) on the button the user pressed to get the
report.
I never see the code going to my error handling on the button. If I
debug, I am in an endless loop with the No data message, followed by
the 2501 message. I suspect my problem is somewhere else - maybe with
the error handling?
Can anyone help? This is VERY frustrating!
Code below.
Thanks so much. I can't release this to the user with this error in it.
sara
[The name of the button is cmdPOReports]
Private Sub cmdPOReports_Cl ick()
On Error GoTo Err_cmdPOReport s_Click
' The user has chosen the frame with all the Pallet Reports
On Error GoTo Err_cmdPOReport s_Click
Dim strDocName As String ' Report as Variable to print
Dim strStepErrorMsg As String ' Description for Error
Dim dtmDate As Date ' Date for File Name
Dim strWhere As String ' Where clause for PO reports
Dim lngMerchantKey As Long
Dim lngDeptNum As Long
Dim strVendor As String
Dim dtmStartDate As Date
Dim dtmEndDate As Date
Dim strBetween As String ' Between dates string for
selection
' Find out what button was chosen, then print preview report for
that choice
Select Case Me.fraPOReports
Case 1 ' POs for a Merchant - Range
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtSt artDate) Then
MsgBox "Please enter the Starting Date for the reports", ,
"W5-Enter Report Date"
Me.txtStartDate .SetFocus
GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtEn dDate) Then
MsgBox "Please enter the Ending Date for the reports", ,
"W5-Enter Report Date"
Me.txtEndDate.S etFocus
GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate
dtmEndDate = Me.txtEndDate
strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate &
"#"
strWhere = " [SuggShipDate] " & strBetween
' If user selected "ALL", show ALL merchants in range
lngMerchantKey = Me.cboMerchant. Column(0)
If lngMerchantKey = 0 Then
strWhere = strWhere
Else
strWhere = "[MerchantKey] = " & lngMerchantKey & " And " &
strWhere
End If
strDocName = "rptPODetai ls"
strStepErrorMsg = "Tell IT there was a problem with Merchant POs"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere
DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
Case 2 ' PO Ship Date Range
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtSt artDate) Then
MsgBox "Please enter the Starting Date for the reports", ,
"W5-Enter Report Date"
Me.txtStartDate .SetFocus
GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter
date
If IsNull(Me.txtEn dDate) Then
MsgBox "Please enter the Ending Date for the reports", ,
"W5-Enter Report Date"
Me.txtEndDate.S etFocus
GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate
dtmEndDate = Me.txtEndDate
strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate &
"#"
strDocName = "rptPODetai ls"
strWhere = " [SuggShipDate] " & strBetween
strStepErrorMsg = "Tell IT there was a problem with Ship date Range
Rpt"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere
DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
.....(There are cases 3-6, but they are nearly identical to the others,
so I deleted the code here to save boring space. If it's needed, I'll
post it)
End Select
Exit_cmdPORepor ts_Click:
Exit Sub
Err_cmdPOReport s_Click:
If Err = 2501 Then
Else
MsgBox "Contact Sara with the following informaiton " _
& Err.Nuumber & "" & Err.Description , , "W5 - Print PO
Reports"
Resume Exit_cmdPORepor ts_Click
End If
End Sub
[In rptPODetails] NO data and On Open
Private Sub Report_NoData(C ancel As Integer)
'Tell the user there is no data
MsgBox "There are no POs for this criteria "
Cancel = True
End Sub
Private Sub Report_Open(Can cel As Integer)
On Error GoTo Err_Report_Open
' Set Sorting and Grouping for this report
Dim strMerch As String
Select Case Forms.frmPrintR eports.fraPORep orts
Case 1
' Merchant Report Sort: Merch Last Name, PO Num, nothing
strMerch = Forms!frmPrintR eports.cboMerch ant.Column(1)
Me.GroupLevel(0 ).ControlSource = "MerchLastN ame"
Me.GroupLevel(1 ).ControlSource = "PONum"
Me.GroupLevel(2 ).ControlSource = "=1"
GoTo Exit_Report_Ope n
Case 2
' Sugg Ship Date Sort: Sugg Ship Date, PO Num, nothing
Me.GroupLevel(0 ).ControlSource = "SuggShipDa te"
Me.GroupLevel(1 ).ControlSource = "PONum"
Me.GroupLevel(2 ).ControlSource = "=1"
GoTo Exit_Report_Ope n
...(Again, there is code for cases 3-6; virtually identical - just
setting the sort order on the report)
End Select
Exit_Report_Ope n:
Exit Sub
Err_Report_Open :
MsgBox "Call Sara with the following information: Err Report Open"
_
& vbCrLf & Err.Number & " " & Err.Description , , "W5 - Error
Report Open Code"
GoTo Exit_Report_Ope n
End Sub
I even tried (based on a posting I saw):
Private Sub Report_Error(Da taErr As Integer, Response As Integer)
Exit Sub
End Sub
Well, you could try this. Also, change the to "informatio n"
Err_cmdPOReport s_Click:
If Err <2501 Then
MsgBox "Contact Sara with the following informaiton " _
& Err.Nuumber & "" & Err.Description , ,_
"W5 - Print PO Reports"
End If
Resume Exit_cmdPORepor ts_Click
End Sub
You'll notice I moved the Resume out of the IF statement in the above
procedure.
Also, I'm not a great fan of GoTos...especia lly when Resume is normally
used. For example, I'd do this instead or using your GoTo.
Err_Report_Open :
MsgBox "Call Sara with the following information: Err Report Open"
Resume Exit_Report_Ope n
End Sub
This may not correct your problem, but it certainly won't hurt either.
sara wrote:
Thanks, Salad (I'm still working on the other db - but this is for
work)
I tried this - along with the spelling correction - and I still get the
same error. Any other ideas?
thanks
Sara
'Here is a typical call to open a report from a form
Private Sub CommandReport_C lick()
On Error GoTo Err_CommandRepo rt
'open report, display data for ID = 1
DoCmd.OpenRepor t "ReportName ", acPreview, , "[ID] = 1"
Exit_CommandRep ort:
Exit Sub
Err_CommandRepo rt:
If Err.Number <2501 Then
MsgBox Err.Number & " - " & Err.Description
End If
Resume Exit_CommandRep ort
End Sub
*************** *************** ***
'here is a typical NoData event I have in the report.
Private Sub Report_NoData(C ancel As Integer)
MsgBox "There are no records to display", vbOKOnly, "No Data"
Cancel = True
End Sub
*************** *************** ****
'here is a typical OnOpen event I have in the report.
Private Sub Report_Open(Can cel As Integer)
DoCmd.Maximize
End Sub
Yours basically looks like mine. You have a bit more processing, but
close enough.
What I would do is enter STOP above a call to a report that has no
data...or click on the vertical bar where the call to open the report
occurs...and step thru the command execution. If you follow your logic,
you'll see it going to the error routine when you didn't expect it to.
I see no reason for your code to have any GoTo's...I see no benefit to
them. I'm trying to be delicate...you' ll get pegged as a lightweight by
others.
I see no reason not to use an If/ElseIf in your code
If IsNull(StartDat e) Then
...code
Elseif IsNull(EndDate) Then
...code
Else
...code
Endif
Stepping thru code will show you where your problem is. Get rid of
every reference to GoTo. In error routines, use Resume instead of GoTo.
salad wrote:
>>sara wrote:
>>>I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report.
Then it seems I still get the 2501 message on the Open Report command, even though I have the code to trap Err 2501 (from many postings - all looked the same to me) on the button the user pressed to get the report.
I never see the code going to my error handling on the button. If I debug, I am in an endless loop with the No data message, followed by the 2501 message. I suspect my problem is somewhere else - maybe with the error handling?
Can anyone help? This is VERY frustrating!
Code below.
Thanks so much. I can't release this to the user with this error in it. sara
[The name of the button is cmdPOReports]
Private Sub cmdPOReports_Cl ick() On Error GoTo Err_cmdPOReport s_Click
' The user has chosen the frame with all the Pallet Reports
On Error GoTo Err_cmdPOReport s_Click
Dim strDocName As String ' Report as Variable to print Dim strStepErrorMsg As String ' Description for Error Dim dtmDate As Date ' Date for File Name
Dim strWhere As String ' Where clause for PO reports Dim lngMerchantKey As Long Dim lngDeptNum As Long Dim strVendor As String
Dim dtmStartDate As Date Dim dtmEndDate As Date Dim strBetween As String ' Between dates string for selection
' Find out what button was chosen, then print preview report for that choice
Select Case Me.fraPOReports
Case 1 ' POs for a Merchant - Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strWhere = " [SuggShipDate] " & strBetween
' If user selected "ALL", show ALL merchants in range
lngMerchantKey = Me.cboMerchant. Column(0)
If lngMerchantKey = 0 Then strWhere = strWhere Else strWhere = "[MerchantKey] = " & lngMerchantKey & " And " & strWhere End If
strDocName = "rptPODetai ls"
strStepErrorMsg = "Tell IT there was a problem with Merchant POs"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click Case 2 ' PO Ship Date Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strDocName = "rptPODetai ls"
strWhere = " [SuggShipDate] " & strBetween
strStepErrorMsg = "Tell IT there was a problem with Ship date Range Rpt" DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
.....(Ther e are cases 3-6, but they are nearly identical to the others, so I deleted the code here to save boring space. If it's needed, I'll post it)
End Select
Exit_cmdPORe ports_Click: Exit Sub
Err_cmdPORep orts_Click: If Err = 2501 Then Else MsgBox "Contact Sara with the following informaiton " _ & Err.Nuumber & "" & Err.Description , , "W5 - Print PO Reports" Resume Exit_cmdPORepor ts_Click End If
End Sub
[In rptPODetails] NO data and On Open
Private Sub Report_NoData(C ancel As Integer)
'Tell the user there is no data
MsgBox "There are no POs for this criteria "
Cancel = True
End Sub
Private Sub Report_Open(Can cel As Integer) On Error GoTo Err_Report_Open
' Set Sorting and Grouping for this report
Dim strMerch As String
Select Case Forms.frmPrintR eports.fraPORep orts
Case 1 ' Merchant Report Sort: Merch Last Name, PO Num, nothing strMerch = Forms!frmPrintR eports.cboMerch ant.Column(1)
Me.GroupLevel(0 ).ControlSource = "MerchLastN ame" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
Case 2 ' Sugg Ship Date Sort: Sugg Ship Date, PO Num, nothing
Me.GroupLevel(0 ).ControlSource = "SuggShipDa te" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
...(Again, there is code for cases 3-6; virtually identical - just setting the sort order on the report)
End Select
Exit_Report_ Open: Exit Sub
Err_Report_O pen: MsgBox "Call Sara with the following information: Err Report Open" _ & vbCrLf & Err.Number & " " & Err.Description , , "W5 - Error Report Open Code" GoTo Exit_Report_Ope n
End Sub
I even tried (based on a posting I saw): Private Sub Report_Error(Da taErr As Integer, Response As Integer) Exit Sub End Sub Well, you could try this. Also, change the to "informatio n" Err_cmdPORepo rts_Click: If Err <2501 Then MsgBox "Contact Sara with the following informaiton " _ & Err.Nuumber & "" & Err.Description , ,_ "W5 - Print PO Reports" End If Resume Exit_cmdPORepor ts_Click
End Sub
You'll notice I moved the Resume out of the IF statement in the above procedure.
Also, I'm not a great fan of GoTos...especia lly when Resume is normally used. For example, I'd do this instead or using your GoTo. Err_Report_Op en: MsgBox "Call Sara with the following information: Err Report Open" Resume Exit_Report_Ope n End Sub
This may not correct your problem, but it certainly won't hurt either.
I'll certainly work on the GoTos and replace with Resume. I am "young"
enough to learn!~
I did step through the code (again - I'd done this before) and it's not
executing my error code at all. I get to the DoCmd.OpenRepor t, run the
OpenReport code (fine), then the NoData (get the message, "OK" it),
Execute the Cancel =True line, End Sub,
and immediately get the 2501 error, and the line that highlights is the
OpenReport line.
I have even put "On Error" immediately above the OpenReport line - I
still don't get my error code executed.
Could it have anything to do with using "Case"?
sara
salad wrote:
sara wrote:
Thanks, Salad (I'm still working on the other db - but this is for
work)
I tried this - along with the spelling correction - and I still get the
same error. Any other ideas?
thanks
Sara
'Here is a typical call to open a report from a form
Private Sub CommandReport_C lick()
On Error GoTo Err_CommandRepo rt
'open report, display data for ID = 1
DoCmd.OpenRepor t "ReportName ", acPreview, , "[ID] = 1"
Exit_CommandRep ort:
Exit Sub
Err_CommandRepo rt:
If Err.Number <2501 Then
MsgBox Err.Number & " - " & Err.Description
End If
Resume Exit_CommandRep ort
End Sub
*************** *************** ***
'here is a typical NoData event I have in the report.
Private Sub Report_NoData(C ancel As Integer)
MsgBox "There are no records to display", vbOKOnly, "No Data"
Cancel = True
End Sub
*************** *************** ****
'here is a typical OnOpen event I have in the report.
Private Sub Report_Open(Can cel As Integer)
DoCmd.Maximize
End Sub
Yours basically looks like mine. You have a bit more processing, but
close enough.
What I would do is enter STOP above a call to a report that has no
data...or click on the vertical bar where the call to open the report
occurs...and step thru the command execution. If you follow your logic,
you'll see it going to the error routine when you didn't expect it to.
I see no reason for your code to have any GoTo's...I see no benefit to
them. I'm trying to be delicate...you' ll get pegged as a lightweight by
others.
I see no reason not to use an If/ElseIf in your code
If IsNull(StartDat e) Then
...code
Elseif IsNull(EndDate) Then
...code
Else
...code
Endif
Stepping thru code will show you where your problem is. Get rid of
every reference to GoTo. In error routines, use Resume instead of GoTo.
salad wrote:
>sara wrote:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report.
Then it seems I still get the 2501 message on the Open Report command, even though I have the code to trap Err 2501 (from many postings - all looked the same to me) on the button the user pressed to get the report.
I never see the code going to my error handling on the button. If I debug, I am in an endless loop with the No data message, followed by the 2501 message. I suspect my problem is somewhere else - maybe with the error handling?
Can anyone help? This is VERY frustrating!
Code below.
Thanks so much. I can't release this to the user with this error in it. sara
[The name of the button is cmdPOReports]
Private Sub cmdPOReports_Cl ick() On Error GoTo Err_cmdPOReport s_Click
' The user has chosen the frame with all the Pallet Reports
On Error GoTo Err_cmdPOReport s_Click
Dim strDocName As String ' Report as Variable to print Dim strStepErrorMsg As String ' Description for Error Dim dtmDate As Date ' Date for File Name
Dim strWhere As String ' Where clause for PO reports Dim lngMerchantKey As Long Dim lngDeptNum As Long Dim strVendor As String
Dim dtmStartDate As Date Dim dtmEndDate As Date Dim strBetween As String ' Between dates string for selection
' Find out what button was chosen, then print preview report for that choice
Select Case Me.fraPOReports
Case 1 ' POs for a Merchant - Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strWhere = " [SuggShipDate] " & strBetween
' If user selected "ALL", show ALL merchants in range
lngMerchantKey = Me.cboMerchant. Column(0)
If lngMerchantKey = 0 Then strWhere = strWhere Else strWhere = "[MerchantKey] = " & lngMerchantKey & " And " & strWhere End If
strDocName = "rptPODetai ls"
strStepErrorMsg = "Tell IT there was a problem with Merchant POs"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click Case 2 ' PO Ship Date Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strDocName = "rptPODetai ls"
strWhere = " [SuggShipDate] " & strBetween
strStepErrorMsg = "Tell IT there was a problem with Ship date Range Rpt" DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
.....(There are cases 3-6, but they are nearly identical to the others, so I deleted the code here to save boring space. If it's needed, I'll post it)
End Select
Exit_cmdPORep orts_Click: Exit Sub
Err_cmdPORepo rts_Click: If Err = 2501 Then Else MsgBox "Contact Sara with the following informaiton " _ & Err.Nuumber & "" & Err.Description , , "W5 - Print PO Reports" Resume Exit_cmdPORepor ts_Click End If
End Sub
[In rptPODetails] NO data and On Open
Private Sub Report_NoData(C ancel As Integer)
'Tell the user there is no data
MsgBox "There are no POs for this criteria "
Cancel = True
End Sub
Private Sub Report_Open(Can cel As Integer) On Error GoTo Err_Report_Open
' Set Sorting and Grouping for this report
Dim strMerch As String
Select Case Forms.frmPrintR eports.fraPORep orts
Case 1 ' Merchant Report Sort: Merch Last Name, PO Num, nothing strMerch = Forms!frmPrintR eports.cboMerch ant.Column(1)
Me.GroupLevel(0 ).ControlSource = "MerchLastN ame" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
Case 2 ' Sugg Ship Date Sort: Sugg Ship Date, PO Num, nothing
Me.GroupLevel(0 ).ControlSource = "SuggShipDa te" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
...(Again, there is code for cases 3-6; virtually identical - just setting the sort order on the report)
End Select
Exit_Report_O pen: Exit Sub
Err_Report_Op en: MsgBox "Call Sara with the following information: Err Report Open" _ & vbCrLf & Err.Number & " " & Err.Description , , "W5 - Error Report Open Code" GoTo Exit_Report_Ope n
End Sub
I even tried (based on a posting I saw): Private Sub Report_Error(Da taErr As Integer, Response As Integer) Exit Sub End Sub
Well, you could try this. Also, change the to "informatio n" Err_cmdPORepor ts_Click:
If Err <2501 Then
MsgBox "Contact Sara with the following informaiton " _
& Err.Nuumber & "" & Err.Description , ,_ "W5 - Print PO Reports"
End If
Resume Exit_cmdPORepor ts_Click
End Sub
You'll notice I moved the Resume out of the IF statement in the above procedure.
Also, I'm not a great fan of GoTos...especia lly when Resume is normally used. For example, I'd do this instead or using your GoTo. Err_Report_Ope n:
MsgBox "Call Sara with the following information: Err Report Open"
Resume Exit_Report_Ope n End Sub
This may not correct your problem, but it certainly won't hurt either.
"sara" <sa*******@yaho o.comwrote in
news:11******** *************@h 48g2000cwc.goog legroups.com:
I'll certainly work on the GoTos and replace with Resume. I
am "young" enough to learn!~
I did step through the code (again - I'd done this before) and
it's not executing my error code at all. I get to the
DoCmd.OpenRepor t, run the OpenReport code (fine), then the
NoData (get the message, "OK" it), Execute the Cancel =True
line, End Sub, and immediately get the 2501 error, and the
line that highlights is the OpenReport line.
I have even put "On Error" immediately above the OpenReport
line - I still don't get my error code executed.
Could it have anything to do with using "Case"?
sara
Sara, open a code module and please check the setting of
Tools->options->general->Error Trapping
Anything except "Break on unhandled errors" might give you this
problem.
>
salad wrote:
>sara wrote:
Thanks, Salad (I'm still working on the other db - but this
is for work)
I tried this - along with the spelling correction - and I
still get the same error. Any other ideas?
thanks
Sara
'Here is a typical call to open a report from a form Private Sub CommandReport_C lick() On Error GoTo Err_CommandRepo rt
'open report, display data for ID = 1 DoCmd.OpenRepor t "ReportName ", acPreview, , "[ID] = 1"
Exit_CommandRe port: Exit Sub
Err_CommandRep ort: If Err.Number <2501 Then MsgBox Err.Number & " - " & Err.Description End If Resume Exit_CommandRep ort End Sub
************** *************** ****
'here is a typical NoData event I have in the report. Private Sub Report_NoData(C ancel As Integer) MsgBox "There are no records to display", vbOKOnly, "No Data" Cancel = True End Sub
************** *************** ***** 'here is a typical OnOpen event I have in the report. Private Sub Report_Open(Can cel As Integer) DoCmd.Maximize End Sub
Yours basically looks like mine. You have a bit more processing, but close enough.
What I would do is enter STOP above a call to a report that has no data...or click on the vertical bar where the call to open the report occurs...and step thru the command execution. If you follow your logic, you'll see it going to the error routine when you didn't expect it to.
I see no reason for your code to have any GoTo's...I see no benefit to them. I'm trying to be delicate...you' ll get pegged as a lightweight by others.
I see no reason not to use an If/ElseIf in your code If IsNull(StartDat e) Then ...code Elseif IsNull(EndDate) Then ...code Else ...code Endif
Stepping thru code will show you where your problem is. Get rid of every reference to GoTo. In error routines, use Resume instead of GoTo.
salad wrote:
sara wrote:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report.
Then it seems I still get the 2501 message on the Open Report command, even though I have the code to trap Err 2501 (from many postings - all looked the same to me) on the button the user pressed to get the report.
I never see the code going to my error handling on the button. If I debug, I am in an endless loop with the No data message, followed by the 2501 message. I suspect my problem is somewhere else - maybe with the error handling?
Can anyone help? This is VERY frustrating!
Code below.
Thanks so much. I can't release this to the user with this error in it. sara
[The name of the button is cmdPOReports]
Private Sub cmdPOReports_Cl ick() On Error GoTo Err_cmdPOReport s_Click
' The user has chosen the frame with all the Pallet Reports
On Error GoTo Err_cmdPOReport s_Click
Dim strDocName As String ' Report as Variable to print Dim strStepErrorMsg As String ' Description for Error Dim dtmDate As Date ' Date for File Name
Dim strWhere As String ' Where clause for PO reports Dim lngMerchantKey As Long Dim lngDeptNum As Long Dim strVendor As String
Dim dtmStartDate As Date Dim dtmEndDate As Date Dim strBetween As String ' Between dates string for selection
' Find out what button was chosen, then print preview report for that choice
Select Case Me.fraPOReports
Case 1 ' POs for a Merchant - Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strWhere = " [SuggShipDate] " & strBetween
' If user selected "ALL", show ALL merchants in range
lngMerchantKey = Me.cboMerchant. Column(0)
If lngMerchantKey = 0 Then strWhere = strWhere Else strWhere = "[MerchantKey] = " & lngMerchantKey & " And " & strWhere End If
strDocName = "rptPODetai ls"
strStepErrorMsg = "Tell IT there was a problem with Merchant POs"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click Case 2 ' PO Ship Date Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strDocName = "rptPODetai ls"
strWhere = " [SuggShipDate] " & strBetween
strStepErrorMsg = "Tell IT there was a problem with Ship date Range Rpt" DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
.....(Ther e are cases 3-6, but they are nearly identical to the others, so I deleted the code here to save boring space. If it's needed, I'll post it)
End Select
Exit_cmdPORe ports_Click: Exit Sub
Err_cmdPORep orts_Click: If Err = 2501 Then Else MsgBox "Contact Sara with the following informaiton " _ & Err.Nuumber & "" & Err.Description , , "W5 - Print PO Reports" Resume Exit_cmdPORepor ts_Click End If
End Sub
[In rptPODetails] NO data and On Open
Private Sub Report_NoData(C ancel As Integer)
'Tell the user there is no data
MsgBox "There are no POs for this criteria "
Cancel = True
End Sub
Private Sub Report_Open(Can cel As Integer) On Error GoTo Err_Report_Open
' Set Sorting and Grouping for this report
Dim strMerch As String
Select Case Forms.frmPrintR eports.fraPORep orts
Case 1 ' Merchant Report Sort: Merch Last Name, PO Num, nothing strMerch = Forms!frmPrintR eports.cboMerch ant.Column(1)
Me.GroupLevel(0 ).ControlSource = "MerchLastN ame" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
Case 2 ' Sugg Ship Date Sort: Sugg Ship Date, PO Num, nothing
Me.GroupLevel(0 ).ControlSource = "SuggShipDa te" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
...(Again, there is code for cases 3-6; virtually identical - just setting the sort order on the report)
End Select
Exit_Report_ Open: Exit Sub
Err_Report_O pen: MsgBox "Call Sara with the following information: Err Report Open" _ & vbCrLf & Err.Number & " " & Err.Description , , "W5 - Error Report Open Code" GoTo Exit_Report_Ope n
End Sub
I even tried (based on a posting I saw): Private Sub Report_Error(Da taErr As Integer, Response As Integer) Exit Sub End Sub
Well, you could try this. Also, change the to "informatio n" Err_cmdPOReport s_Click: If Err <2501 Then MsgBox "Contact Sara with the following informaiton " _ & Err.Nuumber & "" & Err.Description , ,_ "W5 - Print PO Reports" End If Resume Exit_cmdPORepor ts_Click
End Sub
You'll notice I moved the Resume out of the IF statement in the above procedure.
Also, I'm not a great fan of GoTos...especia lly when Resume is normally used. For example, I'd do this instead or using your GoTo. Err_Report_Open : MsgBox "Call Sara with the following information: Err Report Open" Resume Exit_Report_Ope n End Sub
This may not correct your problem, but it certainly won't hurt either.
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
sara, just an idea (it's late and my mind is not at its sharpest), but is it
possible that the error is a database error rather than a vb error, and so
would be better trappable in the error event of the form or report?
-john
"sara" <sa*******@yaho o.comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
I'll certainly work on the GoTos and replace with Resume. I am "young"
enough to learn!~
I did step through the code (again - I'd done this before) and it's not
executing my error code at all. I get to the DoCmd.OpenRepor t, run the
OpenReport code (fine), then the NoData (get the message, "OK" it),
Execute the Cancel =True line, End Sub,
and immediately get the 2501 error, and the line that highlights is the
OpenReport line.
I have even put "On Error" immediately above the OpenReport line - I
still don't get my error code executed.
Could it have anything to do with using "Case"?
sara
salad wrote:
>sara wrote:
Thanks, Salad (I'm still working on the other db - but this is for
work)
I tried this - along with the spelling correction - and I still get the
same error. Any other ideas?
thanks
Sara
'Here is a typical call to open a report from a form Private Sub CommandReport_C lick() On Error GoTo Err_CommandRepo rt
'open report, display data for ID = 1 DoCmd.OpenRepor t "ReportName ", acPreview, , "[ID] = 1"
Exit_CommandRe port: Exit Sub
Err_CommandRep ort: If Err.Number <2501 Then MsgBox Err.Number & " - " & Err.Description End If Resume Exit_CommandRep ort End Sub
************** *************** ****
'here is a typical NoData event I have in the report. Private Sub Report_NoData(C ancel As Integer) MsgBox "There are no records to display", vbOKOnly, "No Data" Cancel = True End Sub
************** *************** ***** 'here is a typical OnOpen event I have in the report. Private Sub Report_Open(Can cel As Integer) DoCmd.Maximize End Sub
Yours basically looks like mine. You have a bit more processing, but close enough.
What I would do is enter STOP above a call to a report that has no data...or click on the vertical bar where the call to open the report occurs...and step thru the command execution. If you follow your logic, you'll see it going to the error routine when you didn't expect it to.
I see no reason for your code to have any GoTo's...I see no benefit to them. I'm trying to be delicate...you' ll get pegged as a lightweight by others.
I see no reason not to use an If/ElseIf in your code If IsNull(StartDat e) Then ...code Elseif IsNull(EndDate) Then ...code Else ...code Endif
Stepping thru code will show you where your problem is. Get rid of every reference to GoTo. In error routines, use Resume instead of GoTo.
salad wrote:
sara wrote:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report.
Then it seems I still get the 2501 message on the Open Report command, even though I have the code to trap Err 2501 (from many postings - all looked the same to me) on the button the user pressed to get the report.
I never see the code going to my error handling on the button. If I debug, I am in an endless loop with the No data message, followed by the 2501 message. I suspect my problem is somewhere else - maybe with the error handling?
Can anyone help? This is VERY frustrating!
Code below.
Thanks so much. I can't release this to the user with this error in it. sara
[The name of the button is cmdPOReports]
Private Sub cmdPOReports_Cl ick() On Error GoTo Err_cmdPOReport s_Click
' The user has chosen the frame with all the Pallet Reports
On Error GoTo Err_cmdPOReport s_Click
Dim strDocName As String ' Report as Variable to print Dim strStepErrorMsg As String ' Description for Error Dim dtmDate As Date ' Date for File Name
Dim strWhere As String ' Where clause for PO reports Dim lngMerchantKey As Long Dim lngDeptNum As Long Dim strVendor As String
Dim dtmStartDate As Date Dim dtmEndDate As Date Dim strBetween As String ' Between dates string for selection
' Find out what button was chosen, then print preview report for that choice
Select Case Me.fraPOReports
Case 1 ' POs for a Merchant - Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strWhere = " [SuggShipDate] " & strBetween
' If user selected "ALL", show ALL merchants in range
lngMerchantKey = Me.cboMerchant. Column(0)
If lngMerchantKey = 0 Then strWhere = strWhere Else strWhere = "[MerchantKey] = " & lngMerchantKey & " And " & strWhere End If
strDocName = "rptPODetai ls"
strStepErrorMsg = "Tell IT there was a problem with Merchant POs"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click Case 2 ' PO Ship Date Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strDocName = "rptPODetai ls"
strWhere = " [SuggShipDate] " & strBetween
strStepErrorMsg = "Tell IT there was a problem with Ship date Range Rpt" DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
.....(Ther e are cases 3-6, but they are nearly identical to the others, so I deleted the code here to save boring space. If it's needed, I'll post it)
End Select
Exit_cmdPORe ports_Click: Exit Sub
Err_cmdPORep orts_Click: If Err = 2501 Then Else MsgBox "Contact Sara with the following informaiton " _ & Err.Nuumber & "" & Err.Description , , "W5 - Print PO Reports" Resume Exit_cmdPORepor ts_Click End If
End Sub
[In rptPODetails] NO data and On Open
Private Sub Report_NoData(C ancel As Integer)
'Tell the user there is no data
MsgBox "There are no POs for this criteria "
Cancel = True
End Sub
Private Sub Report_Open(Can cel As Integer) On Error GoTo Err_Report_Open
' Set Sorting and Grouping for this report
Dim strMerch As String
Select Case Forms.frmPrintR eports.fraPORep orts
Case 1 ' Merchant Report Sort: Merch Last Name, PO Num, nothing strMerch = Forms!frmPrintR eports.cboMerch ant.Column(1)
Me.GroupLevel(0 ).ControlSource = "MerchLastN ame" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
Case 2 ' Sugg Ship Date Sort: Sugg Ship Date, PO Num, nothing
Me.GroupLevel(0 ).ControlSource = "SuggShipDa te" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
...(Again, there is code for cases 3-6; virtually identical - just setting the sort order on the report)
End Select
Exit_Report_ Open: Exit Sub
Err_Report_O pen: MsgBox "Call Sara with the following information: Err Report Open" _ & vbCrLf & Err.Number & " " & Err.Description , , "W5 - Error Report Open Code" GoTo Exit_Report_Ope n
End Sub
I even tried (based on a posting I saw): Private Sub Report_Error(Da taErr As Integer, Response As Integer) Exit Sub End Sub
Well, you could try this. Also, change the to "informatio n" Err_cmdPORepo rts_Click: If Err <2501 Then MsgBox "Contact Sara with the following informaiton " _ & Err.Nuumber & "" & Err.Description , ,_ "W5 - Print PO Reports" End If Resume Exit_cmdPORepor ts_Click
End Sub
You'll notice I moved the Resume out of the IF statement in the above procedure.
Also, I'm not a great fan of GoTos...especia lly when Resume is normally used. For example, I'd do this instead or using your GoTo. Err_Report_Op en: MsgBox "Call Sara with the following information: Err Report Open" Resume Exit_Report_Ope n End Sub
This may not correct your problem, but it certainly won't hurt either.
That's IT!! I finally learned to set break on all errors, and I forgot
to set it back. THANK YOU!!
I feel a combination or relieved and stupid - but mostly grateful!
sara
Bob Quintal wrote:
"sara" <sa*******@yaho o.comwrote in
news:11******** *************@h 48g2000cwc.goog legroups.com:
I'll certainly work on the GoTos and replace with Resume. I
am "young" enough to learn!~
I did step through the code (again - I'd done this before) and
it's not executing my error code at all. I get to the
DoCmd.OpenRepor t, run the OpenReport code (fine), then the
NoData (get the message, "OK" it), Execute the Cancel =True
line, End Sub, and immediately get the 2501 error, and the
line that highlights is the OpenReport line.
I have even put "On Error" immediately above the OpenReport
line - I still don't get my error code executed.
Could it have anything to do with using "Case"?
sara
Sara, open a code module and please check the setting of
Tools->options->general->Error Trapping
Anything except "Break on unhandled errors" might give you this
problem.
salad wrote:
sara wrote:
Thanks, Salad (I'm still working on the other db - but this
is for work)
I tried this - along with the spelling correction - and I
still get the same error. Any other ideas?
thanks
Sara
'Here is a typical call to open a report from a form
Private Sub CommandReport_C lick()
On Error GoTo Err_CommandRepo rt
'open report, display data for ID = 1
DoCmd.OpenRepor t "ReportName ", acPreview, , "[ID] = 1"
Exit_CommandRep ort:
Exit Sub
Err_CommandRepo rt:
If Err.Number <2501 Then
MsgBox Err.Number & " - " & Err.Description
End If
Resume Exit_CommandRep ort
End Sub
*************** *************** ***
'here is a typical NoData event I have in the report.
Private Sub Report_NoData(C ancel As Integer)
MsgBox "There are no records to display", vbOKOnly, "No
Data" Cancel = True
End Sub
*************** *************** ****
'here is a typical OnOpen event I have in the report.
Private Sub Report_Open(Can cel As Integer)
DoCmd.Maximize
End Sub
Yours basically looks like mine. You have a bit more
processing, but close enough.
What I would do is enter STOP above a call to a report that
has no data...or click on the vertical bar where the call to
open the report occurs...and step thru the command execution.
If you follow your logic, you'll see it going to the error
routine when you didn't expect it to.
I see no reason for your code to have any GoTo's...I see no
benefit to them. I'm trying to be delicate...you' ll get
pegged as a lightweight by others.
I see no reason not to use an If/ElseIf in your code
If IsNull(StartDat e) Then
...code
Elseif IsNull(EndDate) Then
...code
Else
...code
Endif
Stepping thru code will show you where your problem is. Get
rid of every reference to GoTo. In error routines, use
Resume instead of GoTo.
salad wrote: sara wrote:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report.
Then it seems I still get the 2501 message on the Open Report command, even though I have the code to trap Err 2501 (from many postings - all looked the same to me) on the button the user pressed to get the report.
I never see the code going to my error handling on the button. If I debug, I am in an endless loop with the No data message, followed by the 2501 message. I suspect my problem is somewhere else - maybe with the error handling?
Can anyone help? This is VERY frustrating!
Code below.
Thanks so much. I can't release this to the user with this error in it. sara
[The name of the button is cmdPOReports]
Private Sub cmdPOReports_Cl ick() On Error GoTo Err_cmdPOReport s_Click
' The user has chosen the frame with all the Pallet Reports
On Error GoTo Err_cmdPOReport s_Click
Dim strDocName As String ' Report as Variable to print Dim strStepErrorMsg As String ' Description for Error Dim dtmDate As Date ' Date for File Name
Dim strWhere As String ' Where clause for PO reports Dim lngMerchantKey As Long Dim lngDeptNum As Long Dim strVendor As String
Dim dtmStartDate As Date Dim dtmEndDate As Date Dim strBetween As String ' Between dates string for selection
' Find out what button was chosen, then print preview report for that choice
Select Case Me.fraPOReports
Case 1 ' POs for a Merchant - Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strWhere = " [SuggShipDate] " & strBetween
' If user selected "ALL", show ALL merchants in range
lngMerchantKey = Me.cboMerchant. Column(0)
If lngMerchantKey = 0 Then strWhere = strWhere Else strWhere = "[MerchantKey] = " & lngMerchantKey & " And " & strWhere End If
strDocName = "rptPODetai ls"
strStepErrorMsg = "Tell IT there was a problem with Merchant POs"
DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click Case 2 ' PO Ship Date Range
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtSt artDate) Then MsgBox "Please enter the Starting Date for the reports", , "W5-Enter Report Date" Me.txtStartDate .SetFocus GoTo Exit_cmdPORepor ts_Click
End If
' Check to see if the date is entered; if not, send a message to enter date If IsNull(Me.txtEn dDate) Then MsgBox "Please enter the Ending Date for the reports", , "W5-Enter Report Date" Me.txtEndDate.S etFocus GoTo Exit_cmdPORepor ts_Click
End If
dtmStartDate = Me.txtStartDate dtmEndDate = Me.txtEndDate strBetween = "Between #" & dtmStartDate & "# and #" & dtmEndDate & "#"
strDocName = "rptPODetai ls"
strWhere = " [SuggShipDate] " & strBetween
strStepErrorMsg = "Tell IT there was a problem with Ship date Range Rpt" DoCmd.OpenRepor t strDocName, acPreview, , strWhere DoCmd.Maximize
GoTo Exit_cmdPORepor ts_Click
.....(There are cases 3-6, but they are nearly identical to the others, so I deleted the code here to save boring space. If it's needed, I'll post it)
End Select
Exit_cmdPORep orts_Click: Exit Sub
Err_cmdPORepo rts_Click: If Err = 2501 Then Else MsgBox "Contact Sara with the following informaiton " _ & Err.Nuumber & "" & Err.Description , , "W5 - Print PO Reports" Resume Exit_cmdPORepor ts_Click End If
End Sub
[In rptPODetails] NO data and On Open
Private Sub Report_NoData(C ancel As Integer)
'Tell the user there is no data
MsgBox "There are no POs for this criteria "
Cancel = True
End Sub
Private Sub Report_Open(Can cel As Integer) On Error GoTo Err_Report_Open
' Set Sorting and Grouping for this report
Dim strMerch As String
Select Case Forms.frmPrintR eports.fraPORep orts
Case 1 ' Merchant Report Sort: Merch Last Name, PO Num, nothing strMerch = Forms!frmPrintR eports.cboMerch ant.Column(1)
Me.GroupLevel(0 ).ControlSource = "MerchLastN ame" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
Case 2 ' Sugg Ship Date Sort: Sugg Ship Date, PO Num, nothing
Me.GroupLevel(0 ).ControlSource = "SuggShipDa te" Me.GroupLevel(1 ).ControlSource = "PONum" Me.GroupLevel(2 ).ControlSource = "=1" GoTo Exit_Report_Ope n
...(Again, there is code for cases 3-6; virtually identical - just setting the sort order on the report)
End Select
Exit_Report_O pen: Exit Sub
Err_Report_Op en: MsgBox "Call Sara with the following information: Err Report Open" _ & vbCrLf & Err.Number & " " & Err.Description , , "W5 - Error Report Open Code" GoTo Exit_Report_Ope n
End Sub
I even tried (based on a posting I saw): Private Sub Report_Error(Da taErr As Integer, Response As Integer) Exit Sub End Sub
Well, you could try this. Also, change the to "information " Err_cmdPOReport s_Click:
If Err <2501 Then
MsgBox "Contact Sara with the following
informaiton " _
& Err.Nuumber & "" & Err.Description , ,_
"W5 - Print PO Reports"
End If
Resume Exit_cmdPORepor ts_Click
End Sub
You'll notice I moved the Resume out of the IF statement in the above procedure.
Also, I'm not a great fan of GoTos...especia lly when Resume is normally used. For example, I'd do this instead or using your GoTo. Err_Report_Open :
MsgBox "Call Sara with the following information: Err
Report Open" Resume Exit_Report_Ope n End Sub
This may not correct your problem, but it certainly won't hurt either.
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
"sara" <sa*******@yaho o.comwrote in
news:11******** *************@i 42g2000cwa.goog legroups.com:
That's IT!! I finally learned to set break on all errors, and
I forgot to set it back. THANK YOU!!
Been there, done that, more than once :-)
I feel a combination or relieved and stupid - but mostly
grateful!
sara
I'll take the relieved, and grateful. You are not stupid.
Forgetful, and possibly preoccupied.
Bob Quintal wrote:
>
Sara, open a code module and please check the setting of Tools->options->general->Error Trapping
Anything except "Break on unhandled errors" might give you this problem.
>
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ColinWard |
last post by:
My previous message was blank so Im trying again. I have a button on a
form which opens the Import dialogue box. This works fine except if I
click on the "X" to close the form I get Run-Time Error 2501: the
DoMenuItem was Cancelled". How can I trap this error so that it doesn't
display but simply closes the form?
Thanks
Colin
|
by: Bob Dydd |
last post by:
Hi everyone
It's me again.
I have an access 2000 database with 12 landscape reports which
sometimes have to be FAXED and other times printed, so I have written
the following code and put it in a module to bring up the print
dialog:
Public Function PrintAccess()
|
by: fearblanco |
last post by:
Hello - I am receiving the below error message when attempting to open
a report. This database is used by approximately 20 users and only one
user is having this problem (even I can't duplicate this error on my
own PC). The command being used is
DoCmd.OpenReport "rptSYS_ChangeInARDaily", acViewPreview
OR
DoCmd.OpenReport...
|
by: Ed Robichaud |
last post by:
I'm temporarily stumped on how to handle/suppress an error (2501) if a user
cancels sending an email. I'm using DoCmd.SendObject to trigger an Outlook
send window, which works OK, but if the msg is cancelled (not sent) then a
VB runtime error msg appears (#2501) that I would like to either hide or
deal with.
-Ed
|
by: Keith |
last post by:
I have the following code in the On No Data event of a report:
****
On Error GoTo err_trap
MsgBox "No items matching criteria.", vbInformation, gcApplication
Cancel = True
err_trap:
If Err.Number = 2501 Then Exit Sub
| |
by: Brian |
last post by:
NOTE ALSO POSTED IN
microsoft.public.dotnet.framework.aspnet.buildingcontrols
I have solved most of my Server Control Collection property issues.
I wrote an HTML page that describes all of the problems that I have
encountered to date and the solutions (if any) that I found....
|
by: Anthony England |
last post by:
I am considering general error handling routines and have written a sample
function to look up an ID in a table. The function returns True if it can
find the ID and create a recordset based on that ID, otherwise it returns
false.
**I am not looking for comments on the usefulness of this function - it is
only to demonstrate error handling**...
|
by: Keith Wilby |
last post by:
In an old A97 app I trap for error 2501 in a report's calling code just in
case there are no records to return (set cancel = True in the report's No
Data event). This doesn't seem to work in my A2k3 version of the same app.
I know I'm missing something simple here but my brain's gone home already.
Anyone help?
Thanks - Keith.
|
by: AccessAl |
last post by:
Sorry for asking but I could not find any response and can only loop thru 25 pages every so often. I know this has been asked multiple times, but I cannot seem to find an answer that I haven 't used.
I use this type of coding when no data exists for a report, but on occasion, My error trapping does not work. I can see no rhyme or reason why it...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |