Instead of On Error Resume Next

  • Thread starter Thread starter Matthew
  • Start date Start date
M

Matthew

I have a multi select extended list box which acts to pass
criteria to a report called on the On Click of a Preview
command button.

For error handling, I have only On Error Resume Next -
which is ok but what I want is to On Error Goto
someErrLable and message that "There Are No Records for
this" and then abort/quit the report and return to my
Switchboard after the user presses OK. I have tried things
like :

On Error GoTo Print_Reports_Show_List_Err

' some print code


Print_Reports_Show_List_Exit:
Exit Function

Print_Reports_Show_List_Err:
MsgBox Error "There Are No Records For This Category"
Resume Print_Reports_Show_List_Exit

But that doesn't do what I want; I have trued Cancel Event
and Quit - but still can't quite get it.


Thanks

Matthew
 
Use the On No Data event in the report under form
properties, put you msgbox and cancel event there

May
MCP in Access and SQL Server
 
trust May, hon, she's right. the NoData event gives you
what you described in your first post. the event only
fires when the report is bound to an empty recordset, so
there is no separate error trapping required. the
procedure is simple:

Private Sub Report_NoData(Cancel As Integer)

MsgBox "Your message."
Cancel = True

End Sub

you can get the details from the Access Help file. :)

-----Original Message-----
Thanks for the reply. Two things :

1. Could you give me the correct syntax for what I am
trying to achieve, as I am not sure that what I show below
is correct.

2. Stephen Lebans has mentioned that Microsoft Techs have
confirmed that the technique which I am using for loading
images into my report (Me![ImageFrame].Picture = Me!
[OLEPathName] & Me![OLEFileName]) causes substantial
memory leaks if used in the On Format event - and tell you
to use the On Print event. The techs are certainly right
in this, as I judge from the performance improvement.

However, using the On No Data event applies to after
Access has formatted the report - and therefore, as I see
it, wouldn't help me as regards to putting in error
handling.

Thanks


Matthew
-----Original Message-----
Use the On No Data event in the report under form
properties, put you msgbox and cancel event there

May
MCP in Access and SQL Server

.
.
 
Actually, if you are opening the report from a form by VBA code, you do need
to trap for the Error 2501 ("User cancelled this action") in the form after
the DoCmd.OpenReport action. This error is returned to the form if the
OnNoData event occurs and the code sets Cancel = True.

--
Ken Snell
<MS ACCESS MVP>

tina said:
trust May, hon, she's right. the NoData event gives you
what you described in your first post. the event only
fires when the report is bound to an empty recordset, so
there is no separate error trapping required. the
procedure is simple:

Private Sub Report_NoData(Cancel As Integer)

MsgBox "Your message."
Cancel = True

End Sub

you can get the details from the Access Help file. :)

-----Original Message-----
Thanks for the reply. Two things :

1. Could you give me the correct syntax for what I am
trying to achieve, as I am not sure that what I show below
is correct.

2. Stephen Lebans has mentioned that Microsoft Techs have
confirmed that the technique which I am using for loading
images into my report (Me![ImageFrame].Picture = Me!
[OLEPathName] & Me![OLEFileName]) causes substantial
memory leaks if used in the On Format event - and tell you
to use the On Print event. The techs are certainly right
in this, as I judge from the performance improvement.

However, using the On No Data event applies to after
Access has formatted the report - and therefore, as I see
it, wouldn't help me as regards to putting in error
handling.

Thanks


Matthew
-----Original Message-----
Use the On No Data event in the report under form
properties, put you msgbox and cancel event there

May
MCP in Access and SQL Server

-----Original Message-----
I have a multi select extended list box which acts to
pass
criteria to a report called on the On Click of a Preview
command button.

For error handling, I have only On Error Resume Next -
which is ok but what I want is to On Error Goto
someErrLable and message that "There Are No Records for
this" and then abort/quit the report and return to my
Switchboard after the user presses OK. I have tried
things
like :

On Error GoTo Print_Reports_Show_List_Err

' some print code


Print_Reports_Show_List_Exit:
Exit Function

Print_Reports_Show_List_Err:
MsgBox Error "There Are No Records For This Category"
Resume Print_Reports_Show_List_Exit

But that doesn't do what I want; I have trued Cancel
Event
and Quit - but still can't quite get it.


Thanks

Matthew
.

.
.
 
Back
Top