Filter columns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 10 columns in a listbox. On top of that there is 10 textboxes which are used to filter the columns. E.g if the textbox for column 1 is filled in with a "F", all records that starts with "F" will be shown as well as the other coulmns for that row. (this far I know how to do it)

Now, if column 2 also is filled in it should only show the records which as the value of textbox1 and textbox2. I.e. if all textboxes is filled in there are 10 criterias. A non filled textbox should filter as "show all".

I can not get the rowsource for the listbox filtered correct.

How should I do this?
 
Here's an example using fields from the 'Employees' table in the 'Northwind'
sample database.

SELECT Employees.LastName, Employees.FirstName, Employees.Title
FROM Employees
WHERE (((Employees.LastName) Like [Forms]![frmTest]![txtLastName] & "*" Or
[Forms]![frmTest]![txtLastName] Is Null) AND ((Employees.FirstName) Like
[Forms]![frmTest]![txtFirstName] & "*" Or [Forms]![frmTest]![txtFirstName]
Is Null) AND ((Employees.Title) Like [Forms]![frmTest]![txtTitle] & "*" Or
[Forms]![frmTest]![txtTitle] Is Null));

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


Fredrik said:
I have 10 columns in a listbox. On top of that there is 10 textboxes which
are used to filter the columns. E.g if the textbox for column 1 is filled in
with a "F", all records that starts with "F" will be shown as well as the
other coulmns for that row. (this far I know how to do it)
Now, if column 2 also is filled in it should only show the records which
as the value of textbox1 and textbox2. I.e. if all textboxes is filled in
there are 10 criterias. A non filled textbox should filter as "show all".
 
Back
Top