Results 1 to 3 of 3
  1. #1
    database_1 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    34

    How to choose a certain column from a combobox for a query criteria


    I have a sub query which is filtered using a combo box on a form. I was able to get the ID of the combo box values but I now want to use the actual names seen on the combo box to use as criteria. I figured out using a msgbox that I can get the name of the combo box values by using me.combobox.Column(1). I then tried to add this to the criteria box in my query but it does not seem to allow the code Forms!Search_frm!combobox.column(1). I am assuming it is the .column(1) since that is the only thing I really changed. Am I writing the criteria code wrong or is there an easier way to do this? Thanks for your time.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Add a hidden textbox to your form (txtSelectedName), make its control source Forms!Search_frm!combobox.column(1) then use it in your query's criteria row Forms!Search_frm!txtSelectedName.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Why use name instead of ID? Names are poor unique identifiers.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 10-16-2019, 11:09 AM
  2. Replies: 3
    Last Post: 11-24-2017, 05:42 AM
  3. Replies: 2
    Last Post: 07-03-2017, 09:10 AM
  4. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  5. Replies: 7
    Last Post: 11-11-2014, 06:10 PM

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