Solved

How to set the value of a textbox

Posted on 2013-11-17
3
284 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

863 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

23 Experts available now in Live!

Get 1:1 Help Now