Gaba,
Public variables can only be referenced in code. To retrieve a public
variable's value in a form, report, query etc you need to write a
function to return its value, and call that from your form etc. For
instance, assuming your public variable is called MyVariable, write a
function in a general module like:
Function GetMyVariable()
GetMyVariable = MyVariable
End Function
Then you can call the function from anywhere in your project. So, to
display its value in a textbox on a form, you would put this in the
textbox's control source:
=GetMyVariable()
That said, that's all theory, but it's not good practice, simply because
public variables are reset as soon as an untrapped error occurs in
your code. Therefore it is safer to use controls on forms to store
values, which do not suffer from this problem. In your particular case,
you would go the other way around, i.e. once the user provides their
username you store it directly in the textbox (or label) on the form
(which, I undertand, remains open at all times anyway), and read it from
there whenever required.
Generally, one can use hidden controls on a form to store values so they
are not seen, or, in the absense of a switchboard or other form that
remains open at all times, one can make a form just for the purpose,
open it at startup and keep it open but hidden as long as the database
is open.
HTH,
Nikos