Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display a public variable in a form 1

Status
Not open for further replies.

SteveCop

Programmer
Jan 11, 2002
24
0
0
GB
I have a form for which the data source is a query on two databases.

Elsewhere in the system, a public variable is set when the system starts running with a user ID name (No fancy code, the public variable is declared in a dedicated module simply as PUBLIC PubUserName as String)

On my form I would like to display this variable and I created a text box whose control source is set at
=[PubUserName]

However the text box only displays #NAME. I have traced the code and the variable has a valid name whilst the form is being displayed.

There must be a simple way round this. Can anyone help please?
 
I dunno if there is a simpler way, but here is my solution.

You declare a public variabble, like Log_ID as string or what not.

Then, make a simple function like this

Function Val_Of_Log_ID()
Val_Of_Log_ID = Log_ID
End Function

Then set your control on your form to be =Val_Of_Log_ID()

Hope that helps,
ChaZ
 
Thanks very much indeed. I'd tried to assign the public to some local variable without success but would never have thought of this trick. A couple of things I found necessary even now 1) the function needs to be declared as a public function and 2) it needs to be in a general module and not in the form module itself otherwise Access doesn't seem to be able to see the function. Anyway SUCCESS so one happy person at this end. Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top