Results 1 to 5 of 5
  1. #1
    Fairportjay is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2019
    Posts
    9

    Pre populating a field

    I am trying to have my field pre populate the users name. I am using a function to look up the current users sign on info.. that works great I then am trying to use that info to prepopulate a field with their full name. I have a table with all the info in it. I tried to use the d lookup but it is not returning a value



    the code is
    =DLookUp("[Name]","Employee listing","User name"= CU())

    Name is the field I want to return from the employee listing table when user name = CU ....... CU is the name of the function that returns the current user name using Environ("USERNAME")

    it has to be something silly I am doing. any help would be welcome

  2. #2
    Join Date
    Mar 2019
    Location
    Netherlands
    Posts
    9
    You could try:

    =DLookUp("[Name]","Employee listing","[User name]=" & CU())

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Should not use reserved words as names for anything. Name is a reserved word. Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention.

    Assume [User Name] is a text field which means parameter needs apostrophe delimiters.
    Code:
    =DLookUp("[Name]", "Employee listing", "[User name]='" & CU() & "'")
    
    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.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    If the suggestion works, it points out why you should never have spaces or special characters in names (save for perhaps underscore). I'd also mention that you should not use reserved words for your names (e.g. Name). See
    http://access.mvps.org/access/general/gen0012.htm
    http://allenbrowne.com/AppIssueBadWord.html

    If the function can return null, your code will experience another problem. DLookup doesn't handle Null very well.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Fairportjay is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2019
    Posts
    9
    so I fixed the naming conventions and works great.. thanks everyone

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

Similar Threads

  1. Replies: 1
    Last Post: 11-06-2017, 10:35 AM
  2. Replies: 1
    Last Post: 06-26-2015, 02:12 PM
  3. populating field in form based on input field
    By BrandonFinn in forum Forms
    Replies: 7
    Last Post: 10-30-2014, 10:45 AM
  4. Replies: 3
    Last Post: 12-14-2013, 12:32 PM
  5. Replies: 4
    Last Post: 07-28-2013, 12:40 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