Query Too Complex

A

A1

I'm used this code
forms!formname!control name or forms!formname!control is null

I open the query i find more than 100 line repated in creteria area
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
like this

the problem is at the end this message appear
Query too complex

How can I reduce the number of
forms!formname!control name or forms!formname!control is null
in creteria area
 
J

John W. Vinson

I'm used this code
forms!formname!control name or forms!formname!control is null

I open the query i find more than 100 line repated in creteria area
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
forms!formname!control name or forms!formname!control is null
like this

the problem is at the end this message appear
Query too complex

How can I reduce the number of
forms!formname!control name or forms!formname!control is null
in creteria area

Why are there <shudder> over 100 criteria...!?

If you have more than four or five form control criteria, it will
probably be worth your while to take a totally different approach. One
such is to write VBA code which creates a SQL string, loops through
the controls on your form, and for each non-NULL control, add an
additional criterion to the string; when you've visited all the
controls, use the SQL string as appropriate (e.g. setting a Report's
Recordsource equal to it).

John W. Vinson [MVP]
 
A

A1

Thank you
another question:
if I use sql code only as record source of the form
I mean (No Query) only sql code
and I have 10 control criteria
is that good for future or must use VBA and SQL
 
J

John W. Vinson

Thank you
another question:
if I use sql code only as record source of the form
I mean (No Query) only sql code
and I have 10 control criteria
is that good for future or must use VBA and SQL

Well, I don't know. I can't see your database, I don't know what
you're searching, I don't know how tolerant your users are, and I
don't even really know what you're trying to accomplish!

Ten "OR" criteria in a query should be reasonable, though if you open
the Query in design view it's going to be REALLY ugly (with ten
calculated fields). It's really your call though!

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top