Filter List Box from command button

Posted on 2011-05-12
Last Modified: 2012-05-11
Dear Experts

Using Access 2010 I am trying to produce an interactive demonstration of data to clients who are interested in staffing numbers and details across Europe.  Rather than using visio / power point I am using access so I can reuse this time and again with the end user simply producing excel spread sheets in the right format that get imported / linked into access.

I have produced a map which resides in a form, using transparent command buttons when the user clicks on a country a list box pops up with the names of their competitors.  That was the easy part - I am keen to apply a filter to the list box from that command button.  

The list box is called “Offices” and contains 2 fields:  “Company” and “Country”. (“Country” is hidden from view).  So for example when I click on Spain the list is filtered by all companies whose “Country” = “Spain”

Can anybody help?
Question by:correlate
    LVL 119

    Accepted Solution

    in the click event of each button, place this

    private sub btn_click()
    me.offices.rowsource="select company,country from tablex where country=" & chr(34) & me.btn.caption & chr(34)

    end sub

    Author Closing Comment

    That's fantastic - thank you and thank you for a record breaking response

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now