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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000, Querying same condition in one or more columns 1

Status
Not open for further replies.

SellOut

Technical User
Jul 5, 2004
30
GB
Hello,

I am making a query that leaves only records with the condition <>"ok" in any one or more of its 30 fields. Is there a way around adding 30 lines and typing <>"ok" in each field with a line to itself? I am open to SQL suggestions as well.

Thanks,

SO
 
WHERE ....
AND Field01 & Field02 & ... & Field30 <> 'okok...ok'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
SellOut, is this a VBA question?

If yes, You could create a string, using a looping structure.

Dim Qry as QueryDef, SQL As String, x As Integer

SQL = "SELECT * FROM WHERE "

For x = 1 To 30

SQL = SQL & "Field" & x & " <> Chr(34) & OK & Chr(34) & " OR "
Next x

SQL = Left(SQL, Len(SQL) - 4)


Set Qry = CurrentDb.CreateQueryDef("QueryName")
Qry.SQL = SQL
Qry.Close

RefreshDatabaseWindow

...not sure, if this is what you're asking?

Either way, good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top