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.
 

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

Similar Threads

Please help 31
Datasheet combo box empty 1
Split form 0
Filter using two criteria 2
linked tables query 9
MS Project Center-Autolink column fields 0
Iff statements 1
Filter Question! 0

Top