Refer to a form instance

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!!
 
M

Marshall Barton

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.
 
A

accesswanabe

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.
 
J

John W. Vinson

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
 
A

accesswanabe

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
 

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