Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I have more than 9 "OR" statements in a query????

Status
Not open for further replies.

supanoods

Programmer
Jun 6, 2002
68
GB
As the title suggests - Can I have more than 9 "OR" statements in a standard query????

I have 13 fields in my table - besides 1 being numeric - the rest are text based, and I want to be able to search upon. I am using: Like "*" & [text] & "*" within each text-based OR statement within the query, but I only have 9 OR's

Is the way around this to code the SQL from the form that I use to run the query (ie button-click)?

Thanks in advance! :)

"If it aint broke - dont fix it!
 
supanoods,

9 OR's means 9 lines to put criteria with OR in query design view? If this is the case, then those 2 separete criteria lines

Like "*" & [text] & "*"
Like "*" & [text] & "*"

equal this 1 criteria line
(Like "*" & [text] & "*") Or (Like "*" & [text] & "*")

I think there is a limit of 255 characters ....
 
I know what you mean by this:

Like "*" & [text] & "*"
Like "*" & [text] & "*"

However I need to have 1 OR staement per field, for example:

"AREA" field - Like "*" & [text] & "*"
OR
"MACHINE" field - Like "*" & [text] & "*"
OR
"PART" field - Like "*" & [text] & "*"
OR
....and so on. It generates a "diagonal" line of OR statements on the Query Design View (if you can picture it). The idea and SQL work fine - but I cant have statements for 3 other fields as there is no space left!



"If it aint broke - dont fix it!
 
OMG OMG OMG What a buttmunch!!!

I have found waht I wanted to do all long....

In the query goto INSERT----> ROWS!!!!!

Talk about making a mountain out of a molehill.... I have missed the obvious!!!!

Thanks anyway Jerry!

"If it aint broke - dont fix it!
 
inserting rows in the table doesn't have anything to do with your select statement?

The easiest thing to do (based on your original post) is to write a query that normalizes your data:


SELECT IdField, "Area" As Title, Area As Value FROM TableName
UNION
SELECT IdField, "Machine", Machine From TableName
UNION
SELECT IdField, "Part", Part From TableName
UNION
(continue for all 13 fields)

Save that as qryNormal and then your final query becomes:

SELECT * FROM qryNormal WHERE Value LIKE "*" & [text] & "*"

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual
 
Leslie, inserting rows in the query grid ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top