Programatically build subform name?

  • Thread starter Thread starter UsenetUser
  • Start date Start date
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
 
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
 
Assuming you mean

strMainform = "NameOfMainForm"
strSubform = "MySubformControlName"

use

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