Solved

How to set the value of a textbox

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 importing text files 13 20
Auto Center Controls on a Form Based on Screen Size/Resolution in MS Access 10 35
Modal form 11 29
Calculation in Access 5 25
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

785 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