Solved

How to set the value of a textbox

Posted on 2013-11-17
3
272 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
  • 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 - Access MVP) earned 500 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now