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
 
Top