passing form name as a variable to a vba statement

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

hi all,
i have the following case i cannot resolve on my own. i have a form that
contains a text box. this text box holds the name of another form. is there a
way to pass the name of the form contained in the text box to a vba statement
like this one for example:

Forms![contents of the text box that is actually the name of a real
form]![some field] = ....[some value]...

10x in advance
 
Peter said:
hi all,
i have the following case i cannot resolve on my own. i have a form that
contains a text box. this text box holds the name of another form. is
there a
way to pass the name of the form contained in the text box to a vba
statement
like this one for example:

Forms![contents of the text box that is actually the name of a real
form]![some field] = ....[some value]...

10x in advance

Yes, this is the syntax you're looking for:

Forms(TextboxValue)![some field] = ....[some value]

Using the parens syntax, you're instructing Access to evaluate it, instead
of treating it as a literal string (ie NOT "TextboxValue", but rather the
contents)
 
Thanks a lot Stuart :)

Stuart McCall said:
Peter said:
hi all,
i have the following case i cannot resolve on my own. i have a form that
contains a text box. this text box holds the name of another form. is
there a
way to pass the name of the form contained in the text box to a vba
statement
like this one for example:

Forms![contents of the text box that is actually the name of a real
form]![some field] = ....[some value]...

10x in advance

Yes, this is the syntax you're looking for:

Forms(TextboxValue)![some field] = ....[some value]

Using the parens syntax, you're instructing Access to evaluate it, instead
of treating it as a literal string (ie NOT "TextboxValue", but rather the
contents)


.
 
Back
Top