Textbox format Decimal Places depends on currency selection

Alhakeem1977

Registered User.
Local time
Today, 14:18
Joined
Jun 24, 2017
Messages
308
Hi Guys,
I have got a textbox representing the amount depends on currency selection, I would like the format of the decimal places to be changed when I select:
1. USD then the decimal places would be 1,223.66
2. KWD then the decimal places would be 1,223.660
here is my code but it's not working:

Code:
Private Sub Form_Current()
On Error Resume Next

If Me.NoOfDigits = "3" Then
Me.txtAmount = Format([txtAmount], " #,###.000")
Else
If Me.NoOfDigits = "2" Then
Me.txtAmount = Format([txtAmount], " #,###.00")
End If
End If

End Sub

Appreciate your suggestions.
 
Hi. The only thing I could think of is to try the Fixed format.
 
Hi. The only thing I could think of is to try the Fixed format.
Thanks theDBguy as I said earler you are always so active.
Do you mean it's not possible?

Sent from my HUAWEI NXT-L29 using Tapatalk
 
Thanks theDBguy as I said earler you are always so active.
Do you mean it's not possible?

Sent from my HUAWEI NXT-L29 using Tapatalk
Hi. I just gave you an idea for a suggestion, so I was thinking it's possible. I just couldn't test it since I don't have a copy of your database. Basically, I was saying if the Format() function isn't working, then try using the Format property using the Fixed settings.
 
Hi. I just gave you an idea for a suggestion, so I was thinking it's possible. I just couldn't test it since I don't have a copy of your database. Basically, I was saying if the Format() function isn't working, then try using the Format property using the Fixed settings.
OK, so how can I change my code to be as a function instead of in the current event?
By the way I prefer to be as a standard format too that would facilitate the auto commas between millolions and thousands.

Thanks a lot in advance!

Sent from my HUAWEI NXT-L29 using Tapatalk
 
When you say 'not working' what is not working?


Code:
tt=12345.66
tt= format(tt," #,###.00")
? tt
 12,345.66
tt= format(tt," #,###.000")
 ? tt
 12,345.660

Hi Guys,
I have got a textbox representing the amount depends on currency selection, I would like the format of the decimal places to be changed when I select:
1. USD then the decimal places would be 1,223.66
2. KWD then the decimal places would be 1,223.660
here is my code but it's not working:

Code:
Private Sub Form_Current()
On Error Resume Next

If Me.NoOfDigits = "3" Then
Me.txtAmount = Format([txtAmount], " #,###.000")
Else
If Me.NoOfDigits = "2" Then
Me.txtAmount = Format([txtAmount], " #,###.00")
End If
End If

End Sub

Appreciate your suggestions.
 
OK, so how can I change my code to be as a function instead of in the current event?
By the way I prefer to be as a standard format too that would facilitate the auto commas between millolions and thousands.

Thanks a lot in advance!

Sent from my HUAWEI NXT-L29 using Tapatalk
Can you post a sample db to play around with?
 
from what gasman and thedbguy posted you will probably need to change the formatting styles of the control, not the value itself.

sort of
controlname.format = "fixed"
controlname.decimals = 3 or 4 etc

I am not sure of the precise names of the control properties.
 
To amplify what my colleagues suggested, a control has a couple of numeric formatting properties and they CAN be dynamically changed. The two that make most sense would be the FORMAT property, which includes all of the "standard" named formats, though you can also provide a template such as "#,###.00" if you wish; and the DecimalPlaces property that lets you set a number or select a value that means "Auto."

Dave is probably right in that you want to set "fixed, 2 decimal places (or 3 decimal places)" for those two fields.

Further, you would do best to set these things in the Form_Load routine, because at that point the controls are available for tailoring.
 
from what gasman and thedbguy posted you will probably need to change the formatting styles of the control, not the value itself.

sort of
controlname.format = "fixed"
controlname.decimals = 3 or 4 etc

I am not sure of the precise names of the control properties.
Thanks a lot, it do the trick I moved my code with your suggestions in the after update event of the currency field, it works fine.

If any body need my full code I will provide it.

Thanks to all of you.

Sent from my HUAWEI NXT-L29 using Tapatalk
 
from what gasman and thedbguy posted you will probably need to change the formatting styles of the control, not the value itself.

sort of
controlname.format = "fixed"
controlname.decimals = 3 or 4 etc

I am not sure of the precise names of the control properties.
It's fine now I got it.

Thank you so much.

Sent from my HUAWEI NXT-L29 using Tapatalk
 
When you say 'not working' what is not working?





Code:
tt=12345.66

tt= format(tt," #,###.00")

? tt

 12,345.66

tt= format(tt," #,###.000")

 ? tt

 12,345.660
I got it work, thank you very much.

Sent from my HUAWEI NXT-L29 using Tapatalk
 

Users who are viewing this thread

Back
Top Bottom