query with isnull or

D

deb

I have a query that needs to display only the records that the field [Title]
is blank or "Project Manager"

I get only project manager or nothing at all.

Please help...


SELECT DISTINCT t040Project.ProjectID, t040Project.ProjectName AS Project,
t040Project.ContractNo AS [Contract#], t14PM.PMName AS [Project Manager],
t14PM.Title
FROM t14PM RIGHT JOIN ((t040Project LEFT JOIN (t041ProjectDetails LEFT JOIN
t000GFacts ON t041ProjectDetails.GFactsID = t000GFacts.GFactsRecordID) ON
t040Project.ProjectID = t041ProjectDetails.ProjectID) LEFT JOIN t041ProjPM ON
t040Project.ProjectID = t041ProjPM.ProjectID) ON t14PM.PMID = t041ProjPM.PmID
WHERE (((t14PM.Title)=(IsNull([title])) Or ([title]="Project Manager")))
ORDER BY t040Project.ProjectName;
 
K

Klatuu

Better practice would be:

WHERE [title] Is Null Or [title]="Project Manager"

IsNull is a VBA function. Is Null is SQL. Although it works okay when using
a Jet database (mdb) (maybe a bit slower), but if you ever have to upsize, it
will fail.
 
J

John W. Vinson

I have a query that needs to display only the records that the field [Title]
is blank or "Project Manager"

Try

WHERE t14PM.[Title] IS NULL Or t14PM.[title]="Project Manager"

Your query was comparing the text string in [Title] with the result of the
IsNull() VBA function (which might be TRUE or FALSE but will never equal the
value in Title!)
 

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