Comparison gives unexpected result

  • Thread starter Thread starter rsosabusiness
  • Start date Start date
R

rsosabusiness

Access 2000 I have a continuous form to record transactions that are
batched together. When the form loads, I ask for the batch total with
an input box and store the input in a variant where I test it for
numerics and zero length input. If OK, I copy it into a box in the
form. As I enter the transactions, I sum them into another box. If the
user attempts to merge the batch with YTD transactions but the two
amounts do not match (txtBatchAmt <> txtTransTotal) , I issue a warning
and stay put. However, if the user inadvertenly tries to merge before
any transactions are recorded, txtTransTotal will be null, but the
comparison will behave as if the two amounts are equal. Although
nothing bad happens because of it, I do not understand how the
comparison gives such result.
Thanks for your help!
Robert
 
Access 2000 I have a continuous form to record transactions that are
batched together. When the form loads, I ask for the batch total with
an input box and store the input in a variant where I test it for
numerics and zero length input. If OK, I copy it into a box in the
form. As I enter the transactions, I sum them into another box. If the
user attempts to merge the batch with YTD transactions but the two
amounts do not match (txtBatchAmt <> txtTransTotal) , I issue a warning
and stay put. However, if the user inadvertenly tries to merge before
any transactions are recorded, txtTransTotal will be null, but the
comparison will behave as if the two amounts are equal. Although
nothing bad happens because of it, I do not understand how the
comparison gives such result.
Thanks for your help!
Robert

Any comparison to a Null value is neither True nor False, but rather returns
Null. Wrap your txtTransTotal in the Nz() function to eliminate that.

If txtBatchAmt <> Nz(txtTransTotal,0)
 
Any comparison to a Null value is neither True nor False, but rather returns
Null. Wrap your txtTransTotal in the Nz() function to eliminate that.

If txtBatchAmt <> Nz(txtTransTotal,0)
Thank you, Rick. Will try that.
Robert
 

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

Back
Top