Link to home
Start Free TrialLog in
Avatar of LarsDyrby
LarsDyrby

asked on

How to set the value of a textbox

I would like to use Environ("Username") to find a value in a table and return this value to a textbox in a form.

Please help me!
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Here is the basic systax:

Me.YourTextBoxName = DLookup("[SomeField]","[SomeTableName]", "[SomeOtherFieldName] = " & Chr(34) & Environ("UserName") & Chr(34) )
Avatar of LarsDyrby
LarsDyrby

ASKER

Copied the code into the controlsource of the textbox

= DLookup("[Center]","[tbl_Brugere]", "[Bruger] = " & Chr(34) & Environ("UserName") & Chr(34) )

but the textbox just shows:

#Name?
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial