Programatically build subform name?

U

UsenetUser

Hi,

Is there a way to do this because I cannot get the syntax right if
there is - tried surrounding the variable with "'" & & "'",
etc.but it looks like it can't be done.

Dim strSubform as string
strSubform = MySubform

'access the subform like this:
Forms!Mainform!strSubform.Form.RecordSource
 
K

Klatuu

You do not directly address the name of the form being used as a subform.
You use the name of the subform control on the main form. The name of the
subform the subform control will contain is identified in the Source Ojbect
property.

To indentify the subform to display, it would be:

Forms!Mainform!SubFormControlName.Form.SourceSourceObject = strSubForm
 
D

Douglas J. Steele

Assuming you mean

strMainform = "NameOfMainForm"
strSubform = "MySubformControlName"

use

Forms(strMainForm).Controls(strSubform).Form.RecordSource
 

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