Resetting a text field to Null

R

RSteph

If I have a text field that holds a user-entered money value. It has a
Validation Rule that the field cannot equal to zero (<> 0). And it is
formatted for Currency.

If I want to then blank out this field (with a clear button), how would I go
about doing this?

I've tried using:

Me!AmountPaid = Null
Me!AmountPaid = ""
Me!AmountPaid.Value = Null
Me!AmountPaid.Text = Null
Me!AmountPaid.Value = ""
Me!AmountPaid.Text = ""

I can't get any of them to clear out the field for me... Any help would be
greatly appreciated.
 
K

Ken Sheridan

If the field's Required property is set to True this prohibits Nulls. If its
AllowZeroLength property is set to False this prohibits zero-length strings.
So if both of these are the case then some value must be entered.

Normally a currency field would have a default value of zero. Null is not a
value, so has no intrinsic meaning and is consequently semantically
ambiguous. What for instance would a Null credit limit mean? No credit?
Unlimited credit? There is no way of knowing, it’s a matter of
interpretation. Also Nulls can cause problems with calculations as they
propagate, i.e. any arithmetical expression involving a Null will result in a
Null regardless of the other values involved.

Its also unusual for a currency value to be stored as text rather than a
number.

If you were to make the field Currency data type and allow zeros, if you
simply want to show it empty for a zero (or a Null if you allow those too)
the you could format the control like this for instance:

$#,##0.00[Black];($#,##0.00)[Red];"";""

This would format it as dollars, showing positive values in black, negative
values in red and parenthesised. To 'clear' the control you'd then set it to
zero:

Me.AmountPaid = 0

Ken Sheridan
Stafford, England
 
M

m3

You can not force the value to be non-zero by "not equal to zero" validation
rule at one hand but on the other hand try to set its value to zero (val("")
= 0)!?
If you want the user to enter some money value, and if you are working on
VBA then you can at some point in your code check the money value entered
and if its zero you prompt the user to enter something > zero.
 

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