Referencing Forms using strings

  • Thread starter Thread starter Paul Overway
  • Start date Start date
P

Paul Overway

In both cases, you are referring to objects that are members of a
collection.

Set frm = Forms(somevariable)

Set ctl = Controls(someothervariable)

Use proper VB syntax instead of Access.
 
Hi, have two questions connected to the same skill that I don't have, but
would love to know.


*** Number One ***

How do I reference a form using a variable?

That is:

Set frm = Forms![resultsform]

Will set frm to my results form. But what if I want to use a variable that
can change
Something like:

FormName="resultsform"

then use this in the set frm line?

*** Number Two ***

If I then wanted to change an object in this form, say:

frm.Controls!SpaceLabel1.Visible = True

But I had a number of spacelabels and wanted to use a variable, say:

NameOfLabel = SpaceLabel1

Then use this in the line?

Thanks

Leonard
 
Thanks Paul this worked really well, although I had to use the
DoCmd.openform in order to get the form into the collection.

Is this always the case?


Much appreciated.

Leonard




Paul Overway said:
In both cases, you are referring to objects that are members of a
collection.

Set frm = Forms(somevariable)

Set ctl = Controls(someothervariable)

Use proper VB syntax instead of Access.

--
Paul Overway
Logico Solutions, LLC
www.logico-solutions.com


McKeown NewsGroup Account said:
Hi, have two questions connected to the same skill that I don't have, but
would love to know.


*** Number One ***

How do I reference a form using a variable?

That is:

Set frm = Forms![resultsform]

Will set frm to my results form. But what if I want to use a variable that
can change
Something like:

FormName="resultsform"

then use this in the set frm line?

*** Number Two ***

If I then wanted to change an object in this form, say:

frm.Controls!SpaceLabel1.Visible = True

But I had a number of spacelabels and wanted to use a variable, say:

NameOfLabel = SpaceLabel1

Then use this in the line?

Thanks

Leonard
 
Back
Top