Forms

J

Justin

Is there a way where I can have a currency text box have a negative sign
Instead of the user pressing (-) sign before the amoutn, i would like the
the user just type the amount and the text box will automatically make it a
negative value
 
6

'69 Camaro

Hi, Justin.
Instead of the user pressing (-) sign before the amoutn, i would like the
the user just type the amount and the text box will automatically make it a
negative value

If one is using the Currency data type, a negative number will display the
dollar amount within parentheses, such as ($100.00), not -$100. One method
of automatically negating the number entered is to multiply the value in the
OnAfterUpdate of the text box. Try:

Private Sub txtDiscount_AfterUpdate()

On Error GoTo ErrHandler

If (Me!txtDiscount.Value > 0) Then
Me!txtDiscount.Value = -1 * Me!txtDiscount.Value
End If

Exit Sub

ErrHandler:

MsgBox "Error in txtDiscount_AfterUpdate( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub

.. . . where txtDiscount is the name of the text box bound to a field of
Currency data type.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
D

Dennis

In the after Update event of your box put this code

[TextBoxName] = [TextBoxName] * -1
 
Top