Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering Records in a Listbox

Status
Not open for further replies.

deweb

Technical User
Jun 27, 2002
23
US
Is it possible to filter records in a listbox using an option group of toggle buttons (A,B,C,D,etc.)? I want the user to be able to filter the list and then double-click on an entry to open the record in another form.

Can this be done? If so, how? If not, is there an alternative?

Thanks.
 
Hi,
You could try seeting the list's Row Source property based on the option the user selects and then requery the list box.

Private Sub Option1_GotFocus()
Me.List1.RowSource="Select x,y,z from tbl1"
Me.List1.Requery
End Sub

Private Sub Option2_GotFocus()
Me.List1.RowSource="Select a,b,c from tbl2"
Me.List1.Requery
End Sub

Private Sub Option3_GotFocus()
Me.List1.RowSource="Select f1,f2,f3 from tbl3"
Me.List1.Requery
End Sub Hope it helps. Let me know what happens.
With regards,
PGK
 
I got pretty much the same code as PGK.. this may help as well:

Private Sub opt1_Click()
opt2.Value = 0
opt3.Value = 0
lstStores.RowSource = "SELECT DISTINCTROW [qryTest].[TestID],[qryTest].[TestCode],[qryTest].[TestName],[qryTest].[TestCity] FROM [qryTest] ORDER BY qryTest.TestCode;"
End Sub

Private Sub opt2_Click()
opt1.Value = 0
opt3.Value = 0
opt4.Value = 0
lstStores.RowSource = "SELECT DISTINCTROW [qryTest].[TestID],[qryTest].[TestCode],[qryTest].[TestName],[qryTest].[TestCity] FROM [qryTest] ORDER BY qryTest.TestID;"
End Sub

Private Sub opt3_Click()
opt2.Value = 0
opt1.Value = 0
lstStores.RowSource = "SELECT DISTINCTROW [qryTest].[TestID],[qryTest].[TestCode],[qryTest].[TestName],[qryTest].[TestCity] FROM [qryTest] ORDER BY qryTest.TestCity;"
End Sub



Simon
 
Thanks. I'll let you know how it goes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top