How to filter form and combobox

J

Jim

My library database has books in to locations--identified as LocationID
= 1 or LocationID = 2 in my tblBooks.

I successfully created an option group on frmBooks that filters the
records so the staff can look at titles in only their location or both
locations. The code is in the afterupdate event of the grpFilterChoice.

This code works for the filter:
Select Case grpFilterChoice
Case 1 ' Show both libraries
Me.FilterOn = False
Case 2 ' Filter on main library
Me.Filter = "locationID = 1"
Me.FilterOn = True 'apply the filter
Case 3 ' filter on Resource Center
Me.Filter = "locationID =2"
Me.FilterOn = True
End Select
Me.Requery

How do I make the comboboxes (cboFindTitle and cboFindAuthor) on
frmBooks reflect the same filter as the form? They currently display all
the records. I'm not sure how to write the code or where to put it.

Thanks for the help!

--Jim
 
V

Van T. Dinh

You need to change the RowSources of the ComboBoxes.

You can use the same posted with extra like:

Select Case grpFilterChoice
Case 1 ' Show both libraries
Me.FilterOn = False
Me.cboFindTitle = {current SQL String}
Me.cboFindAuthor = {current SQL String}

Case 2 ' Filter on main library
Me.Filter = "locationID = 1"
Me.FilterOn = True 'apply the filter

Me.cboFindTitle = {current SQL String and [LocationID] = 1 }
Me.cboFindAuthor = {current SQL String and [LocationID] = 1 }

Case 3 ' filter on Resource Center
Me.Filter = "locationID =2"
Me.FilterOn = True

Me.cboFindTitle = {current SQL String and [LocationID] = 2 }
Me.cboFindAuthor = {current SQL String and [LocationID] = 2 }

End Select
Me.Requery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top