negative number to positive number

JHENDRYX

Registered User.
Local time
Today, 00:25
Joined
Aug 9, 2002
Messages
16
I have a calculator form in Access that I am trying to create a +/- command button in. This should allow the user to switch a number from negative to positive and from positive to negative. Here is the code that I have written.

Private Sub NegativeOrPositive_Click()

If txtReadOut.Value > 0 Then txtReadOut.Value = "-" & Me!txtReadOut.Value
If txtReadOut.Value < 0 Then txtReadOut.Value = " " & Me!txtReadOut.Value

End Sub

changing the number from positive to negative works beautifully, but when I try to switch it from a positive to a negative it stays a negative number. I know that is because of the second If statement. The value that it is using for the Me!txtReadOut.Value field is already a negative number so all it does is put a space infront of the negative number and displays that. Here is my question...how do I get the second statement to not use Me!txtReadOut.Value as a negative number? Is there different code that should be used for this all together?

Thanks,

Jennifer:confused:
 
It seems that Me!txtReadOut is text.

This should work:

Me!txtReadOut = CStr(-1 * CDbl(Me!txtReadOut))


Convert Me!txtReadOut to double, multiply by -1, convert back to string.
 
Thanks for the help. It worked great.

Thanks,

Jennifer
 

Users who are viewing this thread

Back
Top Bottom