The queries look the same in designview??_Again

A

Ann-Sofie Karlsson

Hi
I didn't explain myself carefully. The first guestion gives the right result
but the second question doesn't. And I don't understand how they can look
the same in Access 97:s designview.

I have two queries that look the same in the the designview but has
different SQL code . The results from the queries are also different. I
wonder how they can look the same in designview but give different results.
What's the reason?? It should be in the SQL code but I can't see it.

Here are the two queries

SELECT MSysObjects.Name ,Type FROM MSysObjects
WHERE Not Type Is Null AND (Type=Forms!frmSLT!cboObjTypeFilter OR
Len(Forms!frmSLT!cboObjTypeFilter & '')=0) And Left$([Name],1)<>'~'
ORDER BY Type, MSysObjects.Name;

SELECT MSysObjects.Name , Type FROM MSysObjects
WHERE (Type=Forms!frmSLT!cboObjTypeFilter And Not Type Is Null) AND
Left$([Name],1)<>'~' OR Left$([Name],1)<>'~' AND
Len(Forms!frmSLT!cboObjTypeFilter)=0
ORDER BY Type, MSysObjects.Name;

Please help

Fia
 
J

JohnFol

You are applying different logic in the where condition so you will get
different results

For example, the first part of the first query does a logical AND with Type
being anything but a NULL and either value in the brackets being true (the
forms references)

Not Type Is Null AND (Type=Forms!frmSLT!cboObjTypeFilter OR
Len(Forms!frmSLT!cboObjTypeFilter & '')=0)

In the 2nd query you are ANDing it with only one of the expressions.

(Type=Forms!frmSLT!cboObjTypeFilter And Not Type Is Null)

So, the length of cboObjTypeFilter being zeroin the first doesn't matter,
but in the second it does.
 

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