passing form name as a variable to a vba statement

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
 
S

Stuart McCall

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)
 
P

Peter

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)


.
 

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