[AccessD] Filter form recordset by combo box

A.D.Tejpal adtp at touchtelindia.net
Wed Sep 21 00:12:45 CDT 2005


Gina,

    Manipulation of form's Filter property should prove convenient in your case. This involves a pair of statements similar to the following.
    (a) For code within the form
        Me.Filter = "<Criteria String>"
        Me.FilterOn = True
    (b) For code in a different form
        Forms("<FormName>").Filter = "<Criteria String>"
        Forms("<FormName>").FilterOn = True

    (Filtered results get displayed very promptly and there is no need for performing any requery)

    It has to be kept in view that any filter applied at run time works in tandem with the filter (if any) built into the record source. It becomes filter on filter. It would therefore be necessary to keep the record source free of any filtering pertaining to field/fields of interest.

Best wishes,
A.D.Tejpal
--------------

  ----- Original Message ----- 
  From: Gina Hoopes 
  To: AccessD at databaseadvisors.com 
  Sent: Tuesday, September 20, 2005 22:44
  Subject: [AccessD] Filter form recordset by combo box


  Hi, all. I've got a problem that I can't sort out by myself.

  I have a database being used by a data entry clerk. She needs to see a list of information by department number. I created a simple form with an unbound combo box where she selects the department she wishes to view. She can then do several things based on that selection - view it for printing, export it to Excel, or open a form with that department ID as the form's criteria. 

  Here's the rub -- when she views the list on a form, I'd like to give her the ability to change departments on the fly. So if she's looking at a form filtered for DeptID 104735, she could use a combo box populated with all of the department numbers to change the recordsource for her form's data. The combo box value on the orignal form where she picks the department number provides criteria for the query on which the second form is based. 

  I think perhaps if I could set it up so that the second form's recordsource was set directly from her choice on the first form rather than a query it would be easier for her to change it but I'm having trouble doing that. If this makes sense, has anyone got any good ideas for me?

  Thanks!
  Gina



More information about the AccessD mailing list