Calling a Form by a variable

  • Thread starter SurveyorinVA via AccessMonster.com
  • Start date
S

SurveyorinVA via AccessMonster.com

Good day all,

I have a form that is loaded based upon an option in a table. For example,
depending on the layout the user wants to see they can have either frmTodayA,
frmTodayB or frmTodayC loaded.

When I call the form via:
txtMyForm = "frmToday" & txtLayoutDesignation

Docmd.Open acForm, "txtMyForm" everything works fine

Now I want to change the source object of a subform on my txtMyForm, and I
thought I could use the following designation

Set frmtoday = Forms(txtMyForm)

frmtoday!Mod1Window.SourceObject = txtModule1

Unfortunately it gives me the following error: "The setting you entered is
not valid for this property"

What would be the proper way to reference the form that can be variable?

Thank you in advance.
Chris
 
G

George Nicholson

If ModWindow1 is the name of a control containing the subform and txtModule1
is a string representing the name of a valid form, table, select query or
SQL, then:

frmtoday.Mod1Window.SourceObject = txtModule1

should work (if frmtoday is open).
Note the use of . rather than !, not sure if it makes a difference in this
case or not.
 

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