How to gracefully handle errors generated when opening a form with linked data?

cricketbird

Registered User.
Local time
Yesterday, 21:41
Joined
Jun 17, 2013
Messages
124
When I open an Access DB, it it set to open a Welcome form which runs some code in the 'Form_Open' event. However, if the backend is offline, the 'Form_Open' code will generate an error. In my error handling to the 'Form_Open' function, I have it set to open the "Settings" form where the user can re-link the tables. The Settings window does indeed open as intended, but the Welcome form immediately opens again, hiding the "Settings" window and confusing my users. I think this is because the Welcome form's subsequent 'Form_Load' function has (otherwise necessary) steps that draw the focus back to Form A.

Is there a way to have Form_Open return an error that the Form_Load can use. e.g. if iserror(Form_Open) then do X, else do Y?

Or, what would the best practice be for code that needs to run on the Welcome form that requires access to the backend but also gracefully handles the situation of allowing the user to relink the backend when needed and then resuming running?
 
Try to open the Settings form as a modal instead so it will wait until the user relinks the BE before passing control back to the calling sub.

Cheers,
 
See if this relinker helps
 
Try to open the Settings form as a modal instead so it will wait until the user relinks the BE before passing control back to the calling sub.

Cheers,
I tried this first as the simplest solution, and it worked beautifully! Thank you!
 
Thanks everyone - it wasn't re-linking that was the problem. I ended up moving everything to Form_Open and changing the "settings" form to modal, and that did the trick.
 

Users who are viewing this thread

Back
Top Bottom