missing subforms in error checking

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I've tried to think of scenarios that cause fatal errors. How do I
check for a missing subform on a main form? If the subform is missing I
don't want the main form to open. I've tried several things but can't seem
to get it to work when opening the form from the switchboard or the custom
menu. It works when I open the form from design view when I'm testing the
form. Should I even worry about this scenario? Thanks!
 
How do I check for a missing subform on a main form?
The main form will have a blank spot where the subform should be.
Just fix what is missing.
 
Hello VBAgroupie.

VBAgroupie said:
Hi. I've tried to think of scenarios that cause fatal errors.
How do I check for a missing subform on a main form?
If the subform is missing I don't want the main form to open.

You could try something like this in the form's open event:

On Error GoTo Err_FormOpen
Dim ctl As Control
Dim sName As String
For Each ctl In Me.Controls
If TypeOf ctl Is SubForm Then sName = ctl.Form.Name
Next
Exit Sub
Err_FormOpen:
Cancel = True
Resume Next
I've tried several things but can't seem to get it to work when
opening the form from the switchboard or the custom menu. It works
when I open the form from design view when I'm testing the form.

You could use a wrapper function that opens the form that uses
inline error handling: On Error Resume Next
Should I even worry about this scenario? Thanks!

Don't. In a well tested application, no subform is missing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top