469,270 Members | 1,042 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

How to Filter on a List box

134 100+
I have a listbox which show customer Names on the 1st column and PO numbers on the 2nd column.
When user select the customer and press the OK button, it will access to the PO form.

Problem here is the list will grow longer and longer and I need to scroll up and down to look for the correct PO.

I would like to create a textbox below the listbox form, so when user type the customer name say 3 characters, it will filter only the customer started with 3 characters ,when user type the PO number say 3 char,it will filter all Po started with this number, so the list will be shorter and easy for user to see and select the PO.

I have tried using Filter on, realize that Listbox doesn't allow me to filter like below statement.

Me.Filter = "[customer] Like '*" & Me.txtCust & "*'"
Me.FilterOn = True

Do you have any better idea on how I should I do it, I don;t want to use the query expression that popup and display in a datasheet view, and user can change the data easily.

I am sure, the expert out there can enlighten me.
Dec 17 '06 #1
5 38726
PEB
1,418 Expert 1GB
Hey in the combo boxes it can be done a bit easier!

If u have a combbox and u type the first 3-4 characters the list is limited to the entries that begin with those characters!

But however maybe u want to keep the list?


I have a listbox which show customer Names on the 1st column and PO numbers on the 2nd column.
When user select the customer and press the OK button, it will access to the PO form.

Problem here is the list will grow longer and longer and I need to scroll up and down to look for the correct PO.

I would like to create a textbox below the listbox form, so when user type the customer name say 3 characters, it will filter only the customer started with 3 characters ,when user type the PO number say 3 char,it will filter all Po started with this number, so the list will be shorter and easy for user to see and select the PO.

I have tried using Filter on, realize that Listbox doesn't allow me to filter like below statement.

Me.Filter = "[customer] Like '*" & Me.txtCust & "*'"
Me.FilterOn = True

Do you have any better idea on how I should I do it, I don;t want to use the query expression that popup and display in a datasheet view, and user can change the data easily.

I am sure, the expert out there can enlighten me.
Dec 17 '06 #2
PEB
1,418 Expert 1GB
Me.Filter = "[customer] Like '*" & Me.txtCust & "*'"
Me.FilterOn = True
for the list u should try this Mylistbox is the name of your list! and imagine that for your list you get the information from mytable!

Me!Mylistbox.RowSource= "SELECT * FROM mytable Where [customer] Like '*" & Me.txtCust & "*';"
Dec 17 '06 #3
jamesnkk
134 100+
for the list u should try this Mylistbox is the name of your list! and imagine that for your list you get the information from mytable!

Me!Mylistbox.RowSource= "SELECT * FROM mytable Where [customer] Like '*" & Me.txtCust & "*';"
Wow !, thank you so much, You are really an Expert ! Yes It Work, Hoorah !
Dec 17 '06 #4
I have a really stupid question. When you say add;

Me!Mylistbox.RowSource= "SELECT * FROM mytable Where [customer] Like '*" & Me.txtCust & "*';"

Where exactly do you add that? I go to my combo box properties and then is this added as VBA through an expression or in the row source or what?

Thanks!
Feb 2 '07 #5
Rabbit
12,516 Expert Mod 8TB
From what it looks like to me you'd add it to the After Update event of a text box control.

What happens is they'll type part of the name into a text box. The code will run and change the names that are displayed in the listbox.
Feb 2 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Robin Cull | last post: by
2 posts views Thread by Salad | last post: by
4 posts views Thread by Twayne | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.