Results 1 to 5 of 5
  1. #1
    jppevy is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    7

    Something similar to a LOOKUP in excel

    I have two tables in my db. The primary ID in both tables in the employee ID. The first table is standard information of all employees. The second table has only has one column of employee ids that have taken a vacation this year. Of the hundreds of employees listed in the first table, only a handful have; therefore, on the second table there are about 40 employee ids.



    My task: I want to create a new column in the first table called vacation. Then, if there is an employee that has taken a vacation--their id would be listed in the second table--the column would fill with the word "Taken." If they have not taken a vacation, then it would fill with "not yet."

    I know how to do this in excel with nested a isnumber and match function, that looks this up automatically, but am confused about what is the most efficient way to do this in access.

    Thanks so much everyone.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Generally speaking you shouldn't store the value in the main table, as it's a calculated field. Do you empty the second table out at the beginning of each year? Not how I'd go about it, but you can get the look you want in a query by including both tables. Edit the join so you get all records from the main table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The primary ID in both tables in the employee ID
    Also, this means that you have a one to one relationship between the tables. Not a normal set up.

    I'm just saying........

  4. #4
    jppevy is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    7
    Hey thanks guys for such quick responses. This is just a one-off thing and thats how the db came to me. Its just these two tables.

    I can run the query with the modified join, but I don't know how to have it automatically fill-in either "taken" or "not yet." For instance, in the query the last column shows the IDs of those from the second table only on the rows for when it matches. So that part works. But, i am wondering if there is any way to have it write in something, or do I just have to do it manually?

    Thanks again.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This type of thing:

    Status: IIf(IsNull(SecondTable.ID), "not yet", "taken")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 10
    Last Post: 08-29-2012, 06:45 AM
  2. Similar Names
    By Christine Boissoin in forum Queries
    Replies: 4
    Last Post: 09-09-2011, 07:24 AM
  3. Exporting Lookup Field To Excel
    By HarryScofs in forum Access
    Replies: 1
    Last Post: 07-27-2011, 09:42 AM
  4. Import to Excel from Access column of LOOKUP data type
    By Derek in forum Import/Export Data
    Replies: 1
    Last Post: 12-06-2010, 06:27 PM
  5. Similar to countif
    By JonHFL in forum Access
    Replies: 2
    Last Post: 06-04-2010, 10:55 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