[RESOLVED] Code for currency field !!!
Hi,
rs.Fields("InvoiceDate").Value = Format(Text3.Text, "dd-mm-yyyy")
The above code is written for the text box which shows the date.
Now, what I need is the code for Amount field which shows the invoice amount in the text box. How can it be modified to view like the below:
Rs. 5,000.25
Usually it shows the dollar sign but I don't need and also need to show the decimals also.
Please help.
Re: Code for currency field !!!
Re: Code for currency field !!!
If you want the comma, use this:
VB Code:
Option Explicit
Private Sub Form_Load()
MsgBox Format(5000.25, "#,#.00")
End Sub
if not, use this:
VB Code:
Option Explicit
Private Sub Form_Load()
MsgBox Format(5000.25, "#.00")
End Sub
Re: Code for currency field !!!
FormatNumber() function maybe a better choice:
VB Code:
FormatNumber(5000.25, 2) 'will output [B]5,000.25[/B]
1 Attachment(s)
Re: Code for currency field !!!
Quote:
Originally Posted by Static
Format(Text3,"#,##0.00")
I am using access database and the field property for "AMT" is "CURRENCY".
Please help.
Re: Code for currency field !!!
hi
as u have set the datatype as currency, what ever number u type in the text box is stored as #.00 format. so no need to worry about the format.
the value will be displayed in the currency format only, when u retrive from the db.
Re: Code for currency field !!!
Quote:
Originally Posted by aravindcm
... so no need to worry about the format...
No, no, no... If you don't format - numeric value will appear as it is stored in the database... So if you want to present formated number then use something like the following:
VB Code:
Private Sub Text1_Change()
If IsNumeric(Text1.Text) Then
Text1.Text = FormatNumber(Text1.Text, 2)
End If
End Sub
'OR
Text1.Text = FormatNumber(rs!AMT, 2)
'OR
Text1.Text = FormatNumber(rs.Fields("AMT").Value, 2)
Re: Code for currency field !!!
Quote:
Originally Posted by RhinoBull
No, no, no... If you don't format - numeric value will appear as it is stored in the database... So if you want to present formated number then use something like the following:
VB Code:
Private Sub Text1_Change()
If IsNumeric(Text1.Text) Then
Text1.Text = FormatNumber(Text1.Text, 2)
End If
End Sub
'OR
Text1.Text = FormatNumber(rs!AMT, 2)
'OR
Text1.Text = FormatNumber(rs.Fields("AMT").Value, 2)
It works fine. Thanks a lot.
Re: [RESOLVED] Code for currency field !!!