how to determine if a subform is loaded

G

Guest

Hello,

Trying to figure out a way to determin if a subform is loaded.

I first tried this... 'If
CurrentProject.AllForms("subform").IsLoaded Then

no luck...also tried this

'If CurrentProject.AllForms("form.subform").IsLoaded Then

no go either.

Anybody out there know how to do this?

Thx much,
Doug
 
D

Dirk Goldgar

Doug Goodenough said:
Hello,

Trying to figure out a way to determin if a subform is loaded.

I first tried this... 'If
CurrentProject.AllForms("subform").IsLoaded Then

no luck...also tried this

'If CurrentProject.AllForms("form.subform").IsLoaded Then

no go either.

Anybody out there know how to do this?

Subforms are not members of the Forms collection, and are only
accessible via the Form property of the subform control that has the
subform as its SourceObject. You could loop through all the forms in
the Forms collection, and for each form loop through all the subform
controls to see if any has the form you're looking for as its
SourceObject, and for other subforms loop through all *their* subform
controls, and so on. It would be rather cumbersome, though, and maybe
the specific problem you're trying to solve has a simpler solution.
What is that specific problem?
 
G

Guest

Hi Dirk,

I inherited an application that uses one main form and then loads loads
several subforms based on what data the user has chosen to enter. I would
like to do so new record processing when a specific subform is open.

here is what I have in the on current event....

If Me.NewRecord Then
If CurrentProject.AllForms("subform").IsLoaded Then
DoCmd.OpenForm "f_review_req_fields_dialog", acNormal, , ,
acFormEdit, acDialog
End If
End If

Thx,
Doug
 
D

Dirk Goldgar

Doug Goodenough said:
Hi Dirk,

I inherited an application that uses one main form and then loads
loads several subforms based on what data the user has chosen to
enter. I would like to do so new record processing when a specific
subform is open.

here is what I have in the on current event....

If Me.NewRecord Then
If CurrentProject.AllForms("subform").IsLoaded Then
DoCmd.OpenForm "f_review_req_fields_dialog",
acNormal, , , acFormEdit, acDialog
End If
End If

So the code is running on the main form, and you just need to know which
subform is being displayed in some particular subform control? Is that
what we're talking about? If so, you should check the SourceObject
property of the subform control (that is, the control, on the main form,
that is displaying the subform). Something like ...

If Me.NewRecord Then
If Me!sfSubformControlName.SourceObject = "YourSubformName" Then
DoCmd.OpenForm "f_review_req_fields_dialog", _
acNormal, , , acFormEdit, acDialog
End If
End If
 

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

Top