Update ListBox with Filtered Records

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
I have a forn with Fields, a DropDown and a ListBox. Ithe ListBox shows the Key field for the table only. If you select a key [Word] from the ListBox the form shows that records fields.

The DropDown lists the possible values for a non-key field in the table [Type]. If you select a [Type] from the DropDown only records containing that [Type] are selected with the "Next" button.

The problem is the ListBox still shows the complete Table when a Filter is on but only go's to record of the selected [Type]. I would like the ListBox to only show the Key field records where that record contains the Filtered [Type] record rather that the complete table?

Any ideas?

This is a sample of the code that filters the Table, for one [Type] based upon the forms selected DropDown [Type]:

Private Sub ShowDropDown_AfterUpdate()

If Me.ShowDropDown = "Temperature" Then
DoCmd.ShowAllRecords
DoCmd.ApplyFilter , "Type = 'Temperature'"
End If

DoCmd.Requery "ListBox_Lookup"
Me.Repaint
DoCmd.Restore
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Does anyone know how to set up a dynamic querry to update a list box based upon the field selected from a ComboBox DropDown or any other way of doing the above: ListBox UpDate and still preserve the ListBox's LookUp ability?
 
Upvote 0
You set the listbox scource as a query that use the combobox as criteria. then on the after update event of the cobobox you requery the Listbox

HTH

Peter
 
Upvote 0
Thanks I did that before I posted.
Its a complicated application and I must have another event stepping in or something?

But, I will try your suggestion again, Thanks.
 
Upvote 0
Thanks Peter,
Along your lines, I had to set and re-set the RowSource for the ListBox to a ComboBox value or use the Default All-Records in several Events each time pulling the proper Query.

It now works like a charm.

Thank You for the pointer.
 
Upvote 0

Forum statistics

Threads
1,221,713
Messages
6,161,463
Members
451,708
Latest member
PedroMoss2268

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top