Link to home
Start Free TrialLog in
Avatar of HKComputer
HKComputerFlag for United States of America

asked on

When an error occurs on form load, how do I resume opening after fixing the error?

When my form loads, it does some tLookups to retrieve settings. If the database is missing, renamed, etc., an error occurs. At this point I let the user reconnect to the database. Now I want to resume loading the form again, but it stays stalled wherever the error occurred.  If the error occurred on the open event I could do cancel = true, but that isn't where the error occurrs.  In fact, it doesn't appear to really occur in any procedure so I had to trap on the form's error event.

I've tried to close the form by using a function to close it before reconnecting the tables, but it crashes Access.

The Errors that trigger this relinking action are:
3024, 3043, 3044, 3151, 3146, 3078


Avatar of rockiroads
rockiroads
Flag of United States of America image

Have u tried issuing

Resume Next

or create a label and perform a Goto to that label when u capture the error?
Avatar of HKComputer

ASKER

I tried resume next and it didn't work.

I didn't try the label but I did try sending it back to Form_Load.


I think I may have found a solution now. I'm starting a different form first that is not bound to any of my backend databases. It then performs some tLookups to the backends. If errors occur, everything get's reconnected and then my main form comes up.

The problem is that starting a form bound to a non-existant database makes an "almost" untrappable error occur sometime while the form is opening. And worse yet, it stops all execution of the forms code and you cannot restart it. And as if that isn't bad enough, none of your error handling procedures are allowed to close this form and reopen it because this form called the error procedure, so technically, it is still in the middle of code execution when you try to close it. And that crashes Access.

Oh, the things you learn.
Please close and refund. The solution I listed above worked for me. Thanks -HK
Got it, HK :-) ... that's what the PAQ-refund recommendation means.  Please take a look at your other open questions.

Thanks in advance,

mbizup
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial