PDA

View Full Version : Solved: Listbox filled with rowsource and I want to filter ...



Charlize
08-08-2006, 02:04 PM
I have a listbox filled up with rowsource (because I need columnheads).
There are also some textboxes on the form (4). The problem I have is how do I adjust the list when I type something in the textboxes. So textbox1 filters on first column in the list, textbox2 on 2nd ...

I think I need something with Textbox1_Change() (2,3,4 also). So, how do I combine the four textboxes to filter on the list.

A tip, idea would be helpfull

I think with a list you can do something like this :


private sub textbox1_change()
For cnt = Userform1.listbox1.listcount -1 to 0 step -1
if instr(1,userform1.listbox1.list(cnt), userform1.textbox1.value, vbtextcompare)=0 then
userform1.listbox1.removeitem (cnt)
endif
next cnt
end sub


But how do you combine the four textboxes ???

Charlize

Bob Phillips
08-08-2006, 02:37 PM
I have a listbox filled up with rowsource (because I need columnheads).
There are also some textboxes on the form (4). The problem I have is how do I adjust the list when I type something in the textboxes. So textbox1 filters on first column in the list, textbox2 on 2nd ...

I think I need something with Textbox1_Change() (2,3,4 also). So, how do I combine the four textboxes to filter on the list.

A tip, idea would be helpfull

I think with a list you can do something like this :


private sub textbox1_change()
For cnt = Userform1.listbox1.listcount -1 to 0 step -1
if instr(1,userform1.listbox1.list(cnt), userform1.textbox1.value, vbtextcompare)=0 then
userform1.listbox1.removeitem (cnt)
endif
next cnt
end sub

But how do you combine the four textboxes ???

Charlize

You cannot remove an item from a listbox if it is bound to a data source, you have to remove the item from the data source.