Comparing strings in a query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dawnm.jordan@gmail.com

    #1

    Comparing strings in a query

    Hello Everyone,
    I have a very elementary problem that I just can't seem to get
    passed. I am writing a very simple select query, but it is not
    running properly.

    SELECT qryUnionAging.I nvoice_Number,
    qryUnionAging.I nvoice_Current_ Balance,
    qryUnionBindInv oiceAndInventor y.owner_id
    FROM qryUnionBindInv oiceAndInventor y RIGHT JOIN qryUnionAging ON
    qryUnionBindInv oiceAndInventor y.Invoice = qryUnionAging.I nvoice_Number
    WHERE (((qryUnionBind InvoiceAndInven tory.owner_id)< >"RMP"));

    For some reason, when I run this query it is exluding the RMP records,
    but also excluding any records where the field is blank (Null). I'm
    stumped! Any ideas whould be appreciated.

    Dawn
  • Salad

    #2
    Re: Comparing strings in a query

    dawnm.jordan@gm ail.com wrote:
    Hello Everyone,
    I have a very elementary problem that I just can't seem to get
    passed. I am writing a very simple select query, but it is not
    running properly.
    >
    SELECT qryUnionAging.I nvoice_Number,
    qryUnionAging.I nvoice_Current_ Balance,
    qryUnionBindInv oiceAndInventor y.owner_id
    FROM qryUnionBindInv oiceAndInventor y RIGHT JOIN qryUnionAging ON
    qryUnionBindInv oiceAndInventor y.Invoice = qryUnionAging.I nvoice_Number
    WHERE (((qryUnionBind InvoiceAndInven tory.owner_id)< >"RMP"));
    >
    For some reason, when I run this query it is exluding the RMP records,
    but also excluding any records where the field is blank (Null). I'm
    stumped! Any ideas whould be appreciated.
    >
    Dawn
    You could use NZ()
    WHERE NZ(qryUnionBind InvoiceAndInven tory.owner_id," ")<>"RMP"

    You could also do
    WHERE qryUnionBindInv oiceAndInventor y.owner_id,""<> "RMP" Or _
    qryUnionBindInv oiceAndInventor y.owner_id Is Null

    Mambo

    Comment

    • Allen Browne

      #3
      Re: Comparing strings in a query

      See:
      The Query Lost My Records! (Nulls)
      at:
      How to avoid losing records when creating a query in Microsoft Access. Describes Nulls in criteria, and outer joins.


      To include the Nulls:
      WHERE ((qryUnionBindI nvoiceAndInvent ory.owner_id <"RMP")
      OR (qryUnionBindIn voiceAndInvento ry.owner_id Is Null));

      --
      Allen Browne - Microsoft MVP. Perth, Western Australia
      Tips for Access users - http://allenbrowne.com/tips.html
      Reply to group, rather than allenbrowne at mvps dot org.

      <dawnm.jordan@g mail.comwrote in message
      news:38950bba-d5ac-4d70-bd94-cd8ecb4f0720@m3 6g2000hse.googl egroups.com...
      Hello Everyone,
      I have a very elementary problem that I just can't seem to get
      passed. I am writing a very simple select query, but it is not
      running properly.
      >
      SELECT qryUnionAging.I nvoice_Number,
      qryUnionAging.I nvoice_Current_ Balance,
      qryUnionBindInv oiceAndInventor y.owner_id
      FROM qryUnionBindInv oiceAndInventor y RIGHT JOIN qryUnionAging ON
      qryUnionBindInv oiceAndInventor y.Invoice = qryUnionAging.I nvoice_Number
      WHERE (((qryUnionBind InvoiceAndInven tory.owner_id)< >"RMP"));
      >
      For some reason, when I run this query it is exluding the RMP records,
      but also excluding any records where the field is blank (Null). I'm
      stumped! Any ideas whould be appreciated.
      >
      Dawn

      Comment

      Working...