Find out if a subform is existing or not

carpeneda

Carpeneda
Local time
Today, 09:27
Joined
Mar 5, 2009
Messages
9
Hello,
when my mainform is active form, I need to know if there is a subform existing and how to refer to the subform object if there is one.
This is used for reformatting of all controls in the main + subform.
Is there any function available, I can use to get this information?
Thank you for any help

Eckhard
 
Don't know why you would want to do this but an easier method would be to have public variable in a module, say

Public BolHasSubform As Boolean

Then when you open a form that has a subform in the Form OnLoad sub simply enter

BolHasSubform = True

Otherwise set it to False

Then you can use this flag to respond accordingly.

David
 
I agree with DCrake that it's unusual question, as normally codes pertaining to subforms are usually behind the form's modules so it's a safe assumption. If you're running it from a standard module, I'd like to know why.

But anyway, another way to do this is:

Code:
Dim ctl As Control

For Each ctl In Me.Controls
    If ctl.ControlType = acSubform Then
       ...
    End If
Next
 

Users who are viewing this thread

Back
Top Bottom