Results 1 to 4 of 4

how to filter table records based on Form combo box

  1. #1
    AbdullahGH is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    6

    how to filter table records based on Form combo box

    Hi,,

    I want to know the code for Filter table records based on form combobox value. the table is not in Form. Below code not working:


    [Table_name]![field1].filter= Forms.[Form_Name].[Combo1]

  2. #2
    kd2017 is online now Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    328
    See this thread:
    https://www.pcreview.co.uk/threads/v...cords.2211492/

    I don't recommend letting your users work directly in the tables. For
    one thing, you have much less control. Why not create a continuous form
    (or even a datasheet form) bound to this table; then you can open it
    and supply the where-condition at the same time via the DoCmd.OpenForm
    method.

    If you insist on opening the table directly, there's no way to filter it
    in the same statement that opens it. However, you can filter it in the
    very next statement, like this:

    Dim strCustomerWanted As String

    strCustomerWanted = "Martin Lee"

    Docmd.OpenTable "Customer Inf"
    DoCmd.ApplyFilter , "[customer name]=" & _
    Chr(34) & strCustomerWanted & Chr(34)

    Note the comma that immediately follows the name of the ApplyFilter
    method. That's critical, because it distinguishes the optional
    "FilterName" argument (which we're not using) from the "WhereCondition"
    argument (which we are using).

  3. #3
    AbdullahGH is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    6
    In main form, I have button to compare between some tables. and before compare, I need to make filter based on Form combobox. There are many tables need to compare, those tables not in Main or sub form.

  4. #4
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    1,359
    I have button to compare between some tables.
    Not much context in your post as to what you want to do with the many tables except to compare a value in the tables with a value in a form's combobox.
    Based on that, what about a DLookup for each table?

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

Similar Threads

  1. Filter combo box data based on a form control
    By onechriswhite in forum Forms
    Replies: 6
    Last Post: 08-29-2015, 08:21 PM
  2. Replies: 3
    Last Post: 06-18-2014, 09:40 AM
  3. Replies: 1
    Last Post: 12-29-2013, 10:21 AM
  4. Replies: 5
    Last Post: 01-16-2013, 10:51 AM
  5. filter form based on combo box
    By lloyddobler in forum Forms
    Replies: 8
    Last Post: 09-10-2009, 06:33 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
  •  
Tech Forums: Microsoft Office Forums