Results 1 to 3 of 3
  1. #1
    shinobi is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2016
    Posts
    9

    Subform filter

    Hey there,



    I have a form and a few subforms (they are not linked and relate to different tables - reason being the user being able to access different data sets from one form instead of having several different forms and switching between them).

    One of the subforms is a datasheet. It links to Visits table and shows the following records:
    VisitID, Date, Client, Employee

    Clients and Employees have their own tables that are linked to Visits table


    I was wondering if it is possible to put a combobox on the main form that would filter the datasheet subform by client.

    This can be achieved by rightclicking one of the clients in the subform and applying filter (Equals ClientA) but if there are too many clients the user would have to find the record with the required client first and then apply filter. A client combobox on the main form listing all the clients and then based on the selection filtering the subform would speed up the process. The form and subform are not linked so this probably requires some kind of JOIN operation?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    In a table, tQrys, put 2 fields,
    Caption, Qry

    fill the table with the queries you want in the subForm, and the caption to show in the combo box.
    set cbo col widths: 1;0
    to show the caption, hide the query name.
    when user picks thE item in the cbo, set the form source.

    Code:
    sub combo_afterupdate()
      Me.subform.sourceobject = combo
    end sub

  3. #3
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I was wondering if it is possible to put a combobox on the main form that would filter the datasheet subform by client.
    If your single subform could be a continuous form with a header, you could dispense with the nav buttons and dividing lines and put the combo in the header. The AfterUpdate event of the combo could cause the requery of the subform using the combo as a filter.

    Otherwise, this would mean you'd have to hide/unhide the combo based on the subform in use (I presume it doesn't apply to all subforms) and it would have to be linked to the main form by vba since you couldn't design it that way.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. combo to filter subform from another subform
    By projectpupil7 in forum Access
    Replies: 2
    Last Post: 02-02-2015, 09:31 AM
  2. Replies: 13
    Last Post: 03-09-2014, 02:11 AM
  3. Replies: 1
    Last Post: 08-16-2012, 01:51 PM
  4. Replies: 6
    Last Post: 05-05-2012, 08:43 AM
  5. Pass Subform filter to subform in report
    By camftm in forum Programming
    Replies: 16
    Last Post: 07-19-2011, 07:12 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