variable in textbox

  • Thread starter Thread starter seeker
  • Start date Start date
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
 
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.
 
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.
 
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
 
Back
Top