Results 1 to 7 of 7
  1. #1
    Judasdac is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    4

    Query: Two tables With Yes/No Filed

    Hi All,



    I'm a bit of a newbie to Access and have been struggling with this problem all night.

    I have two tables: one is a list of employees with the unique ID being employee ID. The other table is just a list of employee IDs and is only for those employees who are receiving a bonus this year.

    I have created a field called "bonus" in the main table and would it like it to display "yes" if the person is getting a bonus and "no" if they are not.

    I have tried to do a make table query and use an iif statement in the bonus field, but I can't quite figure it out. The query keeps resulting in a table that shows only the employees that are getting a bonus.

    I'm using an iif statement in the bonus field in query design view:

    IIf([Employee]![Employee ID]=[Bonus![Employee ID],"yes","no")

    As I said this just results in a query with only the employees that are getting bonuses rather than a field with all employees and a "yes" or "no"

    This was pretty easy for me to do in Excel; I just wrote a Vlookup and it worked perfectly. I can't quite figure out in Access though.

    Any ideas?

    Thanks in advance for the assistance!

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    How have you joined the two tables in your make table query. Post your SQL statment for this query.

    Alan

  3. #3
    Judasdac is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    4
    I'm not sure I can't understand how to write the SQL statement. I have been using the query design wizard and the expression builder in design mode.

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Open your query in design view. In the upper left hand corner, there is an icon that looks like a datasheet. Click on the arrow next to it. It will open a drop down. Select SQL and the statement that equates to the design view will appear. Access creates it for you. Copy and paste it into a thread for us to review. Looking at it will also help you to understand what is happening with SQL statements created by Access from the design view.

    Alan

  5. #5
    Judasdac is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    4
    Thank you so much! I just learned something new

    This is the SQL statement:

    SELECT Employees.[Employee ID] AS [Employee_Employee ID], Employees.[First name], , Employees.[Bonus], [Bonus].[Employee ID] AS [Bonus_Employee ID]
    FROM Employees LEFT JOIN [Bonus] ON Employees.[Employee ID] = [Bonus].[Employee ID];

  6. #6
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    I recreated your situation as best as I understood it. Attached is the sample db.

    Is this what you are looking for?

    Alan

  7. #7
    Judasdac is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    4
    This is very helpful! Thank you so much.

    Cheers

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

Similar Threads

  1. Replies: 2
    Last Post: 11-15-2010, 03:57 PM
  2. Replies: 1
    Last Post: 10-10-2010, 05:30 AM
  3. Sum of a categorized filed
    By Costa in forum Reports
    Replies: 0
    Last Post: 02-24-2010, 07:34 AM
  4. Upercase in filed of form
    By miziri in forum Forms
    Replies: 2
    Last Post: 12-23-2009, 05:13 PM
  5. Color change in form filed
    By miziri in forum Programming
    Replies: 3
    Last Post: 08-15-2009, 04:53 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