Results 1 to 6 of 6
  1. #1
    cmartinezn is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2014
    Location
    New York, USA
    Posts
    3

    Enter "yes" or "no" in a table field based on another table

    Hi,

    I apologize if this problem has been discussed in another thread. I have not been able to find it in this forum.

    I have basic knowledge of Access and I am facing the following situation. I have to import 2 different Excel spreadsheets into Access. That's not a problem. One of them contains a list of employees and some details (including their ID number). So the fields for each register would be ID, Name, Last Name, DOB, Region, and so on. The other table is just a list of some of those employee's IDs. Not all the IDs are listed in this second table.

    My problem is, I've been asked to add a new field in the first table, the one with the employee details, that has to show "yes" or "no", based on if that employee's ID appears in the second table or not.

    Could anyone give me some hints on how to proceed? Thank you very much.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Add the field to Table1 manually - a Yes/No field I guess.

    Build an UPDATE query using the query builder.

    Join the two tables on the ID fields, join type "Include all records from Table1 and only those from Table2 that match".

    Under the new field on the Update To row:

    IIf(IsNull(Table2.ID), No, Yes)

    Test this on copy of the destination table first.
    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.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Add a new column to the table. Give the field a Yes/No data type. Give it a default value of 0.

    Create a SELECT query Joining the ID's. Turn your SELECT query into an UPDATE query using the Update button in the ribbon. Update your yes no field to True and run the query.

    Build a second UPDATE query based on the first table. Show all records WHERE the yes no field is null. UPDATE those records to = FALSE

  4. #4
    cmartinezn is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2014
    Location
    New York, USA
    Posts
    3
    Thank you so much for your help. Although I'm not very used to work with Access, I believe I will be able to follow your suggestions. It's the first time that I read about "update query" though

    I really appreciate the time you took to answer my question and I hope you don't mind if I get back to you if I still find myself stuck with this problem.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I suggest you spend some time to understand different approaches to managing nulls in yes no fields. There are two approaches in the two examples here.

  6. #6
    cmartinezn is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2014
    Location
    New York, USA
    Posts
    3
    Will do, thanks!!

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

Similar Threads

  1. Replies: 7
    Last Post: 07-19-2013, 11:58 AM
  2. Replies: 3
    Last Post: 04-22-2013, 06:08 AM
  3. Replies: 8
    Last Post: 03-05-2013, 01:20 PM
  4. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  5. Replies: 16
    Last Post: 07-22-2011, 09:23 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