tags:

views:

104

answers:

2

For a given form in a database, is there a quick/easy way to find all other forms in an Access database use it as a subform?

Note: I am only concerned with main forms that have it defined using the property sheet, it is easy enough to do a code search for any form that dynamically sets it as a subform at runtime.

+1  A: 

It is not too difficult to use VBA to check.

sfrmname="FormToFind"
For Each frm In CurrentProject.AllForms
   DoCmd.OpenForm frm.Name, acDesign
   For Each ctl In Forms(frm.Name).Controls
      If ctl.ControlType=acSubForm Then
         If ctl.SourceObject = sfrmname Then
            Debug.Print frm.Name
         End If
      End If
   Next
   DoCmd.Close acForm, frm.Name
Next

Or there abouts.

Remou
Thanks. That's a good answer and I wrote almost the exact code, but was hesitant about opening each object (lord knows what code is in the onopen of some of them). I hadn't considered opening in design view though. Good answer +1
JohnFx
+3  A: 

Right-click on the form in the database window and select "Object Dependencies" This should give you the list of forms that host it as a sub-form.

DJ
This depend on the version of Access, I guess.
Remou
Right on. Thanks for the quick answer.
JohnFx
It also works only if you have Name Autocorrect turned on, and nobody should do that, since it's buggy and causes both performance problems and corruption of Access objects. It's a feature that is completely unusable in reality.
David-W-Fenton