Results 1 to 9 of 9
  1. #1
    PoorBoy is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    14

    Filtering with combo box


    hi im new, i have a table1 with name and gender. i want to use combo box with male/female to filter. then display to a listbox that display table1
    when click male in combo box will only show male with name at the listbox
    when click female in combo box will only show female with name at the listbox

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Take a look at Form1 in the attched db.
    BTY, "Name" is a reserved word in access so it should not be used as the name of any object. See: http://support.microsoft.com/kb/286335
    FName, FirstName, LName, LastName, would be better.
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Siiig is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    30
    Hey Bob,

    I was looking at the DB you put together here. I tried to re-create it from scratch, just for practice, but got caught up on your OnRefresh.

    What does that VB code to?

  4. #4
    PoorBoy is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    14
    it works thx , i want to add "both" in the gender and 1 more field into the table "Available At" with morning/afternoon/night same thing with gender for filter.

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Siiig View Post
    Hey Bob,

    I was looking at the DB you put together here. I tried to re-create it from scratch, just for practice, but got caught up on your OnRefresh.

    What does that VB code to?
    OnRefresh . Perhaps you mean:
    Code:
    Private Sub cmbGender_AfterUpdate()
      Me.lstFNames.Requery
    End Sub
    This requeries the combo box which has criteria set in the SELECT statement of its Row Source property that restricts the data in the list box to records that have the same gender as that which is selected in the combo box
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    Siiig is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    30
    Quote Originally Posted by Bob Fitz View Post
    OnRefresh . Perhaps you mean:
    Code:
    Private Sub cmbGender_AfterUpdate()
      Me.lstFNames.Requery
    End Sub
    This requeries the combo box which has criteria set in the SELECT statement of its Row Source property that restricts the data in the list box to records that have the same gender as that which is selected in the combo box
    Yup, you got it right Bob. After I read your VB code (I'm not sure what the proper name for this is) I understand what it's aiming to do, but after replicating it I'm still not getting desirable results.

    Any chance you might take a peek at my attempt to recreate? Maybe you can find something that's obviously wrong.

    The test data was actually based on another thread. These two seemed to go well together.
    Attached Files Attached Files

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    siiig

    I have made a couple of changes
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    Siiig is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    30
    Hey Bob, I just ran through the settings in there, and I can't seem to locate what you changed

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    I removed the first column of the combo box by changing the Row Source property. Also changed the Column Count and Column Widths properties of the combo
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Record filtering through Combo box
    By glen in forum Forms
    Replies: 5
    Last Post: 12-21-2012, 03:43 PM
  2. Replies: 1
    Last Post: 07-12-2012, 08:39 AM
  3. Replies: 5
    Last Post: 03-12-2012, 02:58 AM
  4. Combo Box Not filtering
    By ss2020 in forum Forms
    Replies: 4
    Last Post: 01-17-2012, 01:16 PM
  5. Replies: 0
    Last Post: 08-17-2008, 12:19 PM

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