variable in textbox

S

seeker

I have read Mr. Snell's guidance regarding global variable in a textbox.
This is what happens when I put a variable in a textbox. I enter it in the
control source as

="Breakthrough Work Experience for " & strname

and when I leave the control source it converts to

="Breakthrough Work Expericence for " & [strname]

which causes a parameter box to appear when the report is opened by a button
on a work experience form. When the button on the form is clicked public
strname is populated with cmbname.column(1). Thanks for your wisdom
 
D

Duane Hookom

You can't use variable names in control sources. I doubt Ken had suggested
that. He might have provided a solution that calls a function that returns a
global variable.
 
M

Marshall Barton

seeker said:
I have read Mr. Snell's guidance regarding global variable in a textbox.
This is what happens when I put a variable in a textbox. I enter it in the
control source as

="Breakthrough Work Experience for " & strname

and when I leave the control source it converts to

="Breakthrough Work Expericence for " & [strname]

which causes a parameter box to appear when the report is opened by a button
on a work experience form. When the button on the form is clicked public
strname is populated with cmbname.column(1). Thanks for your wisdom


variables are VBA things and are not available outside the
VBA environment. The only VBA things that can be used in
nearly any other environment (queries, control source
expressions, etc) are Public Functions.

To do what you described, it would be easier to use a
(hidden?) text box instead of a variable. If you really
want to use a variable, then you have to create a function
similar toL

Public Function GetName()
GetName = strName
End Function

Note that strName must be declared with scope that includes
the function. This is normally done by using
Dim strName As String
at the top of the same module that contains the function.
 
S

seeker

sorry did not mean to misquote Ken his comment was "In a report, you can
refer to the variable by name. I placed the variable and phrase to
lblHeader.caption on report open. Thanks for your help on both issues.

Duane Hookom said:
You can't use variable names in control sources. I doubt Ken had suggested
that. He might have provided a solution that calls a function that returns a
global variable.

--
Duane Hookom
Microsoft Access MVP


seeker said:
I have read Mr. Snell's guidance regarding global variable in a textbox.
This is what happens when I put a variable in a textbox. I enter it in the
control source as

="Breakthrough Work Experience for " & strname

and when I leave the control source it converts to

="Breakthrough Work Expericence for " & [strname]

which causes a parameter box to appear when the report is opened by a button
on a work experience form. When the button on the form is clicked public
strname is populated with cmbname.column(1). Thanks for your wisdom
 

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