Results 1 to 4 of 4
  1. #1
    t_dot is offline Novice
    Windows XP Access 97
    Join Date
    Aug 2010
    Posts
    17

    Post Code for two comboBoxes

    Hi, I have a form with two comboboxes on it and I can get it to output from both of them from one query when a button is pushed, however I can only get one to work at a time. It is set up that there is one table and each combobox filters entries by one column each (one is for ASSET TYPE and the other is for EVENT) so that when the button is pushed, a table is created filtered by these two options. Right now, it filters by ASSET TYPE then EVENT, however the second overwrites the first each time. I know that the first search works as well since I can comment out the second and it filters by ASSET TYPE instead. How can I change this so it filters by the first AND the second?
    ****
    CODE:
    If Combo10.Value & "" = "" Then 'If none picked, show all


    strWHERE = ""
    Else
    strWHERE = "WHERE [ASSET TYPE]='" & Combo10.Value & "'"
    End If

    If Combo14.Value & "" = "" Then
    strWHERE2 = ""
    Else
    strWHERE2 = "WHERE [EVENT]='" & Combo14.Value & "'"
    End If


    SQL = "SELECT " & strSelect & " FROM [TransmissionInformation] " & strWHERE

    CurrentDb.QueryDefs("FindAssetFormQuery").SQL = SQL
    SQL = "SELECT " & strSelect & " FROM [TransmissionInformation] " & strWHERE2

    CurrentDb.QueryDefs("FindAssetFormQuery").SQL = SQL

    DoCmd.OpenQuery "FindAssetFormQuery"
    DoCmd.Close acForm, "AssetNumberMenuForm", acSaveYes

    ***

    I am very new to access and this type of coding, so any help is appreciated... I've tried to be as descriptive as possible, but hopefully it's not confusing. Thanks!

  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,530
    Try

    SQL = "SELECT " & strSelect & " FROM [TransmissionInformation] " & strWHERE & " AND " & strWHERE2

    but you'll need to get rid of the "WHERE" in the second.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    t_dot is offline Novice
    Windows XP Access 97
    Join Date
    Aug 2010
    Posts
    17
    Wow... haha well now it works just fine... Sorry for asking such a silly question! But thanks so much!!

  4. #4
    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!
    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. Subform with Comboboxes
    By Angate in forum Forms
    Replies: 5
    Last Post: 04-23-2010, 08:10 PM
  2. How to Reset Comboboxes
    By bbarrene in forum Programming
    Replies: 5
    Last Post: 01-23-2010, 11:11 PM
  3. Cascaded comboboxes in a form
    By luca in forum Forms
    Replies: 2
    Last Post: 11-22-2009, 05:36 AM
  4. subform comboboxes/Textboxes
    By terryvanduzee in forum Forms
    Replies: 2
    Last Post: 11-19-2009, 07:41 PM
  5. Refreshing comboboxes in a subform
    By KB_Dev in forum Programming
    Replies: 1
    Last Post: 04-07-2009, 12:12 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