Combo Selection

M

Missy

I want to be able to pull data on a subform by multiple
cbo's. If I select cbo 1, it gives everything equal to
that. If I select cbo 1 and cbo 2, it gives everything
equal to the both. If I select cbo 1, cbo 2, and cbo 3,
it does the same. Very new to this and have a little
code - just not working. It is possible that someone
could provide an example code for me to go by. I also
would like to see ALL records in the subform if I don't
select anything. I really need help. Thanks in advance
for anyone's assistance.
 
A

ABL

Missy said:
I want to be able to pull data on a subform by multiple
cbo's. If I select cbo 1, it gives everything equal to
that. If I select cbo 1 and cbo 2, it gives everything
equal to the both. If I select cbo 1, cbo 2, and cbo 3,
it does the same. Very new to this and have a little
code - just not working. It is possible that someone
could provide an example code for me to go by. I also
would like to see ALL records in the subform if I don't
select anything. I really need help. Thanks in advance
for anyone's assistance.

Try the following:
me!subform_name.recordsource= "SELECT field1, field2, field3, field4, field
5, field6" _
& "FROM tablename " _
& "WHERE (field1 = " & cbo1.value & " OR ISNULL(" & cbo1.value & ") AND " _
& "(field2 = " & cbo2.value & " OR ISNULL(" & cbo2.value & ") AND " _
& "(field3 = " & cbo3.value & " OR ISNULL(" & cbo3.value & ") ;"

Good Luck!

Alden

Please reply to the newsgroup.
 
M

Missy

I comprehend that you are pulling ALL cbo's at one time.
I want to be able to do it based on selection to generate
records. So that code is useless. Right now my code is
filtering the data on AfterUpdate (Set Me.Recordset =
FilterData)for cbo 1. But when I do cbo 2 or 3, not
recognized. Hope this is not too confusing. I see alot
of the same questions about multiple combo are being asked
and still waiting on an answer.
 
Top