Results 1 to 5 of 5
  1. #1
    catguy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Minnesota
    Posts
    20

    Option button to apply filter

    I am looking for some help/advice in programming an option button in a form.
    Specifically, I have a form with a combo box and 2 text boxes.
    The combo box contains a list (Vendor), and the text boxes are used to input a date range, and a command button to run everything. These are tied to a query which contains all of the records. Enter the "Vendor" number, start date and end date and click the OK button. The query runs and returns only records for the search criteria... works great. The idea was for anyone to export the results to excel and do what they want with the data... but now someone wants to click a button to apply a filter (laziness if you ask me), anyway, I'm not quite sure of the best way to do it. If the button is active, the filter is applied, if not active, the filter is not applied.


    I have attached a sample DB. I don't know if I should use code, an expression or..... Either way, I'm fairly new to Access and VBA and am a bit stumped. Thanks

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    What is the Filter?

    Also, I would advise against using field and object names that include spaces. Sooner or later it will come back and bite you.
    I would also suggest you create a relationship diagram -- define the relations between your tables. Opt for referential integrity.
    Define the PKs for your tables.

    To help put these points into context, take a look at the first few topics at this link
    http://www.rogersaccesslibrary.com/forum/topic238.html

  3. #3
    catguy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Minnesota
    Posts
    20
    Oops.... I knew I was forgetting something.
    The filter is to remove any record that has "2X" in the "UD Code" column.
    Thanks for the advise. Unfortunately I have inherited the DB my sample came from, and after taking a good close look at it, am very afraid
    It takes forever to update, which must be done manually. My goal is to clean it up and automate it quite a bit... ahhhh... ambition.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I think you could do a lot of what you're doing using vba, but I set up an approach that I have included in the attached jpg.

    Created a second query QryVendFiltered. It includes the <>'2X' criteria for field UD. You Run this query if the Filter Option is selected.
    You run QryVend if the Filter Option is not selected.
    You can see the change in the OK Click code.

    I'm sure there are lots of other possibilities,but it depends on what you really need. Will there be more filters etc?

  5. #5
    catguy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Minnesota
    Posts
    20
    Works a charm.... thanks so much for your help.
    I plan on doing quite a bit with VBA when I revamp the existing DB, so I'm sure I'll be posting more.
    I understand the concepts and structure of VBA, so writing the main code isn't too much of an issue, it's the the little things that trip me up a bit, but I usually stumble over enough humps to figure out what I need to do.
    Thanks again

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

Similar Threads

  1. Use Option Group to Filter Combo Box Values
    By dgj32784 in forum Programming
    Replies: 2
    Last Post: 06-06-2011, 12:04 PM
  2. Apply Filter based on unbound date boxes
    By anoob in forum Access
    Replies: 3
    Last Post: 01-21-2011, 05:26 PM
  3. Replies: 5
    Last Post: 10-06-2010, 07:28 PM
  4. Problem on Option Button
    By cwwaicw311 in forum Forms
    Replies: 2
    Last Post: 02-10-2010, 10:44 AM
  5. Apply filter command
    By miziri in forum Forms
    Replies: 6
    Last Post: 01-21-2010, 02:22 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