Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting Question: Percentage and Currency in the same txtBox 1

Status
Not open for further replies.

Cleis

Technical User
Jun 4, 2000
197
US
Group:

I have a table that has two fields

1. Field Name "Factor" which can either have "$" or "%"
2. Field Name "Value" which is a Data Type = Double

I have a form that the user 1st selects the "$" or "%". Based on the selection in the cmboFactor, I want the "Value text box" to be masked or formatted accordingly. Since the data type is a double this should work for both currency and percentages . . . . right?

So I thought I would try the following:

Private Sub txtFactor_AfterUpdate()

If cmboFactor = "%" Then

Me![txtValue] = Format([txtValue], "0.00%")

ElseIf cmboFactor = "$" Then

Me![txtValue] = Format([txtValue], "$0.00")
End If

End Sub

It doesn't work? 2 questions:

1. Why doesn't this work even if the dataType is Double?
2. Would I be better off setting up the necessary fields for both currency and percentages and manage the data entry from the form into the proper field?

I have searched quite a bit to no avail. This leads me to believe that #2 is the better option?

Thanks!

Itch
 
what about this ?
If cmboFactor = "%" Then
Me![txtValue].Format = "0.00%"
Else
Me![txtValue].Format = "$0.00"
End If


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
THANKS PHV!!

Curious though . . . why didn't my 1st approach work?? Same thing isn't it??


Here is a star for your input!

Regards!

Itch
 
Same thing isn't it
Absolutely not the same thing.
My code changes the format property, your code converts a numeric value to a formatted string.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV!

One of these days I'll get it all straight!

Regards!

Itch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top