Hello:
I'm having some difficulties with handling a NoData event from a report, and I'm not entirely sure why I'm having them.
1. I have a form that grabs some info from a user, sets a query, and then opens my report.
2. I have some OnActivate code in the report which formats the report.
3. I'd like to ALSO have my NoData event handle situations where there are no records for the report.
I've set cancel = True for this step and have also added some error trapping code similar to RoyVidar's suggestions for bypassing error 2501 in the form VBA.
Here's the thing:
When I run the form/report, I get the message I included in the NoData event, so I know that is firing properly.
I also get a message I included in the ErrorTrap segment of my Form code, so I know that is firing.
However, once those items fire, Access just sits there and hangs, whereas I'd just like the user to be able to continue working with the form.
Obviously, I'm missing something, but I'm not quite sure what, maybe I need to handle the error differently, say using "On Error Resume Next" instead?
Right now I just have a statement like "On Error GoTo ErrorTrap:" that jumps to the error handling segment I've placed at the bottom of my form code.
Even more frustrating is that once I REMOVE the NoData event handling code the report opens up perfectly, no hangs or crashes, but has errors due to the lack of records (ie: none).
Obviously, I'd like to avoid opening up the report entirely in those cases where there are no records.
Maybe a DAO recordset example would do that better.
I can post more detailed code examples, but was wondering if there was any thoughts as to what might be the cause here - can I NOT use both the OnActivate AND NoData events at the same time?
Thanks.
marcus101
marcus101
Access/SQL/XML Developer
Ottawa, Canada
I'm having some difficulties with handling a NoData event from a report, and I'm not entirely sure why I'm having them.
1. I have a form that grabs some info from a user, sets a query, and then opens my report.
2. I have some OnActivate code in the report which formats the report.
3. I'd like to ALSO have my NoData event handle situations where there are no records for the report.
I've set cancel = True for this step and have also added some error trapping code similar to RoyVidar's suggestions for bypassing error 2501 in the form VBA.
Here's the thing:
When I run the form/report, I get the message I included in the NoData event, so I know that is firing properly.
I also get a message I included in the ErrorTrap segment of my Form code, so I know that is firing.
However, once those items fire, Access just sits there and hangs, whereas I'd just like the user to be able to continue working with the form.
Obviously, I'm missing something, but I'm not quite sure what, maybe I need to handle the error differently, say using "On Error Resume Next" instead?
Right now I just have a statement like "On Error GoTo ErrorTrap:" that jumps to the error handling segment I've placed at the bottom of my form code.
Even more frustrating is that once I REMOVE the NoData event handling code the report opens up perfectly, no hangs or crashes, but has errors due to the lack of records (ie: none).
Obviously, I'd like to avoid opening up the report entirely in those cases where there are no records.
Maybe a DAO recordset example would do that better.
I can post more detailed code examples, but was wondering if there was any thoughts as to what might be the cause here - can I NOT use both the OnActivate AND NoData events at the same time?
Thanks.
marcus101
marcus101
Access/SQL/XML Developer
Ottawa, Canada