Results 1 to 2 of 2
  1. #1
    RoyLittle0 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2012
    Posts
    25

    Auto fill text box based on login information from Environ("username")

    Hi I have some forms which require the user to insert their name, when filling out data, is it possible to automatically insert their name based on the Environ("username") information I have a hidden text box on each form, that contain the Environ("username").

    The user information is stored in "Employees" table under "UserName" and the full name is in a Query that looks up the FirstName and LastName from the Employees Table. Query is "Employees Extended" and the value is Employee Name.

    the fields I want to auto fill are lookup fields from the "Employees Extended".
    Any help would be appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes, that is possible. Requires code. I use only VBA and don't know if macro can accomplish.

    If the field you want to populate is included in the form's RecordSource, could be simply:
    Me!fieldname = DLookup("LastName","Employees","UserName='" & Environ("USERNAME") & "'")

    However, it is best to save employee ID instead of name.

    The real trick is figuring out what event to put the code in.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 02-05-2013, 10:57 PM
  2. Replies: 6
    Last Post: 12-28-2012, 02:54 PM
  3. Replies: 2
    Last Post: 09-29-2012, 11:22 PM
  4. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  5. Replies: 15
    Last Post: 04-01-2011, 11:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums