Filter Question

B

Bob

I have a List Box from a query on my form that has a field ClientID and 2
other fields and on my form I have one ClientID, How can I filter the list
box to only show the two other fields with the same ClientID in the list
Box, Thanks for any Help
 
H

hmadyson

Start off with the listbox having no Recordsource. Then once the clientID is
chosen, in the AfterUpdate event set Recordsource = "Select * from MyTable
where clientid=[value of clientid]. Then choose listbox.requery. It would
look something like

Sub MyField_AfterUpdate()
Dim lngCltID As Long

lngCltID = Me.txtClientID
Me.lstBox.RowSource = "Select * from MyTable Where ClientID=" & lngCltID
Me.lstBox.Requery
End sub

Note that if the clientids are not chosen on the form, you will want to use
the Form_Current() event to run this code.

Pleaset let me know if I can provide more assistance.
 
Top