By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 993 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

Where Clause Problem in SQL statement

P: n/a
I'm creating a query with a where statement using VBA to create a DAO
recordset. I've separated the query to make it easier to read. This
is the query:

SELECT [test].Race, Count([test].Race) AS CountOfRace
FROM [test]

WHERE ((([test].[Name])='BSS 101/OUT 101')
AND (([test].[Codes])='WORKBOC0104')
AND (([test].[Completed Training])=True))

OR ((([test].[Name])='BSS 101/OUT 101')
AND (([test].[Codes])='WORKBOC0304')
AND (([test].[Completed Training])=True))

OR ((([test].[Name])='BSS 101/OUT 101')
AND (([test].[Codes])='WORKPTA0104')
AND (([test].[Completed Training])=True))

OR ((([test].[Name])='BSS 101/OUT 101')
AND (([test].[Codes])='WORKPTA0304')
AND (([test].[Completed Training])=True))

OR ((([test].[Name])='Common Cents - Fiscal Controls')
AND (([test].[Codes])='PRCDFIS0104')
AND (([test].[Completed Training])=True))

GROUP BY [test].Race;

As you can see each where statement uses this same statement:
AND (([test].[Completed Training])=True

My question is there an easier way to create this statement without
having to use "AND (([test].[Completed Training])=True" each time?

Thanks in advance for the help.
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
WHERE ( (a=b and c=d) or (e=f and g=h) or (i=j and k=l) .... ) and
trainingcomplete = true

--
Dutchy
Ecohouse <vi*******@netzero.com> schreef in berichtnieuws
dd**************************@posting.google.com...
I'm creating a query with a where statement using VBA to create a DAO
recordset. I've separated the query to make it easier to read. This
is the query:

SELECT [test].Race, Count([test].Race) AS CountOfRace
FROM [test]

WHERE ((([test].[Name])='BSS 101/OUT 101')
AND (([test].[Codes])='WORKBOC0104')
AND (([test].[Completed Training])=True))

OR ((([test].[Name])='BSS 101/OUT 101')
AND (([test].[Codes])='WORKBOC0304')
AND (([test].[Completed Training])=True))

OR ((([test].[Name])='BSS 101/OUT 101')
AND (([test].[Codes])='WORKPTA0104')
AND (([test].[Completed Training])=True))

OR ((([test].[Name])='BSS 101/OUT 101')
AND (([test].[Codes])='WORKPTA0304')
AND (([test].[Completed Training])=True))

OR ((([test].[Name])='Common Cents - Fiscal Controls')
AND (([test].[Codes])='PRCDFIS0104')
AND (([test].[Completed Training])=True))

GROUP BY [test].Race;

As you can see each where statement uses this same statement:
AND (([test].[Completed Training])=True

My question is there an easier way to create this statement without
having to use "AND (([test].[Completed Training])=True" each time?

Thanks in advance for the help.

Nov 13 '05 #2

P: n/a
Thanks for the help. That worked for me. I knew I was close, but you
can see what happens when you use the MS Access Query Builder.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.