Results 1 to 5 of 5
  1. #1
    tylerpickering is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    22

    Query Based on Form Checkbox


    Hello,

    I have a form setup that will allow a user to check a check box if they want to pull data with certain equipment types (logistics/trucking). I am unsure how to do this in the query...basically (picture attached) I want them to select the equipment type (ex. Dry Van and Temp Controlled) out of seven options and then only those records get pulled in. How do I do this in the "criteria" field?

    Thanks so much for the help!
    Click image for larger version. 

Name:	form.PNG 
Views:	14 
Size:	14.3 KB 
ID:	18683

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    1 way, is at on RUN QRY button, a macro runs to add each item to a table, tEqFind.
    In the macro is a query to add each item to this table.

    docmd.openquery "qdEmptyTbl"
    (insert into tEqFind [EQ].. where forms!frmFind!chkBulk = true)
    (insert into tEqFind [EQ].. where forms!frmFind!chkVan = true)
    etc. (if true they get added)

    join this tEqFind table to your data table on EQ field, and ONLY those items will retreive.

  3. #3
    tylerpickering is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    22
    Thanks for the reply!

    Is using VBA the only/best way to go about doing it?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    no, i gave you the NON vb method....(easiest)
    the other way with vb would be

    2.
    build the SQL for the query on button click

    Code:
    dim sSql, sWhere
    
    if chkBulk.value then sWhere = sWhere & "[eq]='BULK', "
    if chkVan.value then sWhere = sWhere & "[eq]='VAN',"
    ... all variations
    
    'remove last comma here
    
    if len(sWhere) > 0 then sWhere = " WHERE " & sWhere
    
    sSql = "select * from tEquip " & sWhere
    docmd.opensql sSql
    'longer more painful way to get it done.

  5. #5
    tylerpickering is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    22
    Thanks again!

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

Similar Threads

  1. Query sums based on checkbox criteria?????
    By mrmims in forum Queries
    Replies: 2
    Last Post: 07-06-2014, 02:42 PM
  2. Replies: 7
    Last Post: 07-11-2013, 10:45 AM
  3. Form Checkbox Query
    By rlsublime in forum Access
    Replies: 1
    Last Post: 03-12-2012, 12:10 PM
  4. Replies: 7
    Last Post: 11-26-2010, 07:54 PM
  5. Automatic checkbox based on value entered in form
    By w00tage19 in forum Database Design
    Replies: 2
    Last Post: 07-12-2010, 04:20 AM

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