?
Solved

How to set the value of a textbox

Posted on 2013-11-17
3
Medium Priority
?
316 Views
Last Modified: 2013-11-19
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!
0
Comment
Question by:LarsDyrby
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75
ID: 39654975
Here is the basic systax:

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

Author Comment

by:LarsDyrby
ID: 39655034
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?
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 39655233
Humm ...  not seeing the problem assuming Center is the Field you want the value from, tbl_Brugere is the table, and Bruger is what you are trying to match with Environ.

I notice
tbl_Brugere  and Bruger   ... is one of these a typo by chance ??

You might try without the brackets also

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question