Refer to a form instance

  • Thread starter Thread starter accesswanabe
  • Start date Start date
A

accesswanabe

How would I refer to a form instance in respect to assigning it to a subform
control's SourceObject property?

Dim Subform1 As New [Form_FormName]
Me.SubformControl.SourceObject = "Subform1"

The above throws Runtime error 2101. "The setting you entered is not valid
for this property."

Thanks much!!
 
Thanks for the reply. I'm attempting to reuse a form in two subform controls
on a main form. I would like to manipulate the record sources and objects of
each independantly without creating a whole new form object. I was thinking
that instantiating the form would be the way to go. Is there a better way
perhaps?

Marshall Barton said:
accesswanabe said:
How would I refer to a form instance in respect to assigning it to a subform
control's SourceObject property?

Dim Subform1 As New [Form_FormName]
Me.SubformControl.SourceObject = "Subform1"

The above throws Runtime error 2101. "The setting you entered is not valid
for this property."

The SourceObject property requires a string containing the
name of the form object. With that, Access creates an
instance automatically.
 
Is there a better way
perhaps?

Yes.

You can reference each subform control's Form object independently:

Me!subform1.Form.Recordsource = something

Me!subform2.Form.Recordsource = something else
 
Thanks Marsh and John. Great advice!

John W. Vinson said:
Yes.

You can reference each subform control's Form object independently:

Me!subform1.Form.Recordsource = something

Me!subform2.Form.Recordsource = something else
 
Back
Top