Results 1 to 10 of 10
  1. #1
    GeirA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    10

    Use of checkboxes in query

    First of all, english is not my mother language - so please excuse my spelling mistakes.



    I have 3 tables in a database (MS Access 2010)

    Click image for larger version. 

Name:	operators.png 
Views:	18 
Size:	8.3 KB 
ID:	22474 Click image for larger version. 

Name:	Equipment.png 
Views:	18 
Size:	11.0 KB 
ID:	22475 Click image for larger version. 

Name:	Authorized.png 
Views:	18 
Size:	9.5 KB 
ID:	22476

    I would like to display all equipment for one operator and checkboxes to indicate if they are authorized.

    Click image for larger version. 

Name:	Result.png 
Views:	17 
Size:	1.8 KB 
ID:	22477

    I have tried different join syntaks, but no luck. Any one who can guide me in the right directions??

    Thanks!

  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,972
    Conventional approach would be to only save a record in Authorized for valid operator/equipment combination.

    Should build a form for data entry/edit, not work directly with tables and queries. Options:

    1. single form bound to Authorized with comboboxes to select operator and equipment

    2. main form bound to Operators and subform bound to Authorized with combobox to select equipment

    3. main form bound to Equipment and subform bound to Authorized with combobox to select operator
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Quote Originally Posted by June7 View Post
    Conventional approach would be to only save a record in Authorized for valid operator/equipment combination.
    That appears to be the case already.

    GeirA, I think it can be done with 2 queries. First a query with no join to get all combinations (the Cartesian product):

    SELECT Operators.ID, Equipment.ID
    FROM Equipment, Operators
    ORDER BY Operators.ID, Equipment.ID;

    Then a query based on that one and the authorized table:

    SELECT qryOperatorsAndEquip.Operators.ID, qryOperatorsAndEquip.Equipment.ID, IIf(IsNull([authorized].[EquipmentID]),False,True) AS Authorized
    FROM qryOperatorsAndEquip LEFT JOIN Authorized ON (qryOperatorsAndEquip.Equipment.ID = Authorized.EquipmentID) AND (qryOperatorsAndEquip.Operators.ID = Authorized.OperatorID)
    ORDER BY qryOperatorsAndEquip.Operators.ID, qryOperatorsAndEquip.Equipment.ID;

    Base a form or report on that and you should have your result.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Okay, get it now. Want to show all available equipment regardless of status and then highlight equipment authorized for operator. Yep, Paul's suggestion is common approach.
    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.

  5. #5
    GeirA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    10
    Thanks a lot! I had no idea I could use 2 queries.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Happy to help! By the way your English is very good. One correction, it's "syntax" rather than "syntaks".
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    GeirA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    10
    Quote Originally Posted by pbaldy View Post
    One correction, it's "syntax" rather than "syntaks".
    Thanks - syntaks is a norwegian word, and is the same as syntax in english. Sometimes when words are so similar, it slips into my writing :-)

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Ah! Well, you're doing a lot better than I would be if I tried to speak Norwegian!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    GeirA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    10
    Hmmm - I thought I understood the second query. But when I try to get the Equipment name into the report - Ms Access ask me for a parameter for the eqname field.

    I have done this:
    SELECT Operators.ID, Equipment.ID, Equipment.EqName
    FROM Equipment, Operators
    ORDER BY Operators.ID, Equipment.ID;

    SELECT qryOperatorsAndEquip.Operators.ID, qryOperatorsAndEquip.Equipment.ID, qryOperatorsAndEquip.Equipment.EqName, IIf(IsNull([authorized].[EquipmentID]),False,True) AS Authorized
    FROM qryOperatorsAndEquip LEFT JOIN Authorized ON (qryOperatorsAndEquip.Equipment.ID = Authorized.EquipmentID) AND (qryOperatorsAndEquip.Operators.ID = Authorized.OperatorID)
    ORDER BY qryOperatorsAndEquip.Operators.ID, qryOperatorsAndEquip.Equipment.ID;

    But when I try to run this last query I get this:

    Click image for larger version. 

Name:	parameter.png 
Views:	12 
Size:	4.5 KB 
ID:	22506
    Last edited by GeirA; 10-26-2015 at 05:31 AM. Reason: Spelling error

  10. #10
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I have done this:
    SELECT Operators.ID, Equipment.ID, Equipment.EqName
    FROM Equipment, Operators
    ORDER BY Operators.ID, Equipment.ID;
    When you have two fields with the same name in the same query, it is best to give them aliases, i.e.
    Code:
    SELECT Operators.ID as OperatorID, Equipment.ID as EquipmentID, Equipment.EqName
    FROM Equipment, Operators
    ORDER BY Operators.ID, Equipment.ID;
    Then when you reference this in your second query, you would reference them like:
    qryOperatorsAndEquip.OperatorID
    qryOperatorsAndEquip.EquipmentID

    (I don't think it like it when you have two periods in a single field like you did before).

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

Similar Threads

  1. Select all checkboxes in a query
    By tconcepcion in forum Queries
    Replies: 8
    Last Post: 01-15-2015, 01:29 PM
  2. Update query for checkboxes
    By scoe in forum Queries
    Replies: 2
    Last Post: 06-20-2014, 07:12 AM
  3. Replies: 1
    Last Post: 06-03-2013, 08:57 AM
  4. Filter Query based upon Checkboxes
    By olinms01 in forum Queries
    Replies: 2
    Last Post: 01-21-2013, 11:38 AM
  5. Issue with Counts of Checkboxes in Query
    By JamiB1979 in forum Queries
    Replies: 3
    Last Post: 06-29-2011, 02:41 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