Results 1 to 2 of 2
  1. #1
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265

    Having a VLOOKUP in the primary key field?


    I have some employee data to import into Access but this data does not have employee ID numbers. I would like to assign employeeID numbers to each person then set the employeeID field as the primary key.

    Here is what I had in mind. I would create a table that defines each employee with an EmployeeID number. Then in the table containing the imported data, the first field would be called EmployeeID. After importing the Excel data into this table, initially this EmployeeID column would be blank because the data in the Excel file doesn't have an employeeID. But the employeeID field would have a VLOOKUP formula that would look at each person's name and cross reference that with the employeeID table in order to obtain the employee ID for each person on each row. Then the VLOOKUP would return the employeeID number. Furthermore, I would like to have this employeeID field set as the primary key.

    Is this possible? Can you do a VLOOKUP in Access? If so, can the employeeID field still be used as the primary key field, even though its values would be determined by a VLOOKUP?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    Access equivalent is DLookup. Can't use domain aggregate functions in table. So the answer to your question is No - cannot use DLookup this way.

    You should run an UPDATE sql action to populate the EmployeeID field. Why would this be primary key? If you already have the employee in the database, why would this ID be unique value in this table?

    Can you guarantee the imported employee name will ALWAYS be spelled the same?
    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: 13
    Last Post: 12-23-2013, 09:20 AM
  2. Replies: 6
    Last Post: 12-16-2012, 08:43 AM
  3. Replies: 5
    Last Post: 06-17-2012, 10:14 PM
  4. Replies: 3
    Last Post: 06-23-2011, 07:39 PM
  5. Sorting on field other than primary key
    By usmcgrunt in forum Access
    Replies: 24
    Last Post: 08-30-2010, 07:15 PM

Tags for this Thread

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