how to change a negative calculated value to zero

Local time
Today, 22:49
Joined
Jul 12, 2006
Messages
70
Please help.
How do i convert a negative value to zero in a Form?
:confused:
 
Hello:
If you had a field on your form named Field1 then in the AfterUpdate event for that control you place the following code:
'
Private Sub Field1_AfterUpdate()
If Val(Field1) < 0 Then Field1 = 0

End Sub
'
Regards
Mark
 
Hi Mark,
I tried the code but it doesn't work. The calculated field still reflects a negative value.

Sheila
 
Hello,

Assume your form has 3 fields Field1, Field2 and Field3. Field3 calculates the values of Field1 less Field2, enter the following formula in Field3

=IIF([Field1]-[Field2]<0,0,[Field1]-[Field2]).

The previous example using AfterUpdate does not work because the AfterUpdate event is not triggered when the field is a calculated field or updated by Visual Basic.

Regards
Dave
 

Users who are viewing this thread

Back
Top Bottom