Emergency combo box

  • Thread starter Thread starter Dr. Selima
  • Start date Start date
D

Dr. Selima

Dear All,
I have a problem, here, I have solved it before but I can't remember
how could I,
I have a query based on two tables for a hospital administration,
and have a Search form with three unbound comboboxes one for the Name,
Date of birth, and the last for Date of admission,
I need to use these search criteria so that it is not a must to fill
them all, i mean i can fill in the name or date of birth or date of
admission, and run a the query by a command button
Regards
 
Dear All,
I have a problem, here, I have solved it before but I can't remember
how could I,
I have a query based on two tables for a hospital administration,
and have a Search form with three unbound comboboxes one for the Name,
Date of birth, and the last for Date of admission,
I need to use these search criteria so that it is not a must to fill
them all, i mean i can fill in the name or date of birth or date of
admission, and run a the query by a command button
Regards

There are a couple of ways to do this; the simplest for three fields
would be to use criteria such as

WHERE ([Name] = [Forms]![SearchForm]![cboName] OR
[Forms]![SearchForm]![cboName] IS NULL)
AND
([Birthdate] = "#" & [Forms]![SeachForm]![cboDOB] OR
[Forms]![SearchForm]![cboDOB] IS NULL)
....
 
Thanks for your reply, but actually I have 8 select fields, and when I make
the query it states that it is a complex filter, filter will be cancelled,
the passibility combinations is very big that the SQL view of the query is
about 5 pages.
is there another way, or VB code?
Thanks

John Vinson said:
Dear All,
I have a problem, here, I have solved it before but I can't remember
how could I,
I have a query based on two tables for a hospital administration,
and have a Search form with three unbound comboboxes one for the Name,
Date of birth, and the last for Date of admission,
I need to use these search criteria so that it is not a must to fill
them all, i mean i can fill in the name or date of birth or date of
admission, and run a the query by a command button
Regards

There are a couple of ways to do this; the simplest for three fields
would be to use criteria such as

WHERE ([Name] = [Forms]![SearchForm]![cboName] OR
[Forms]![SearchForm]![cboName] IS NULL)
AND
([Birthdate] = "#" & [Forms]![SeachForm]![cboDOB] OR
[Forms]![SearchForm]![cboDOB] IS NULL)
...
 
Thanks for your reply, but actually I have 8 select fields, and when I make
the query it states that it is a complex filter, filter will be cancelled,
the passibility combinations is very big that the SQL view of the query is
about 5 pages.

With 8 fields you're right - this simple approach becomes very
complex! VBA code is the way to go; loop through the eight (or however
many) fields, building up a SQL string as you go. There are examples
on the web but I can't put my finger on one right away.
 
Back
Top