Jan 24th, 2006, 11:05 AM
#1
Thread Starter
Fanatic Member
[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.
Jan 24th, 2006, 11:07 AM
#2
Re: Code for currency field !!!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Jan 24th, 2006, 11:09 AM
#3
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
Jan 24th, 2006, 11:11 AM
#4
Re: Code for currency field !!!
FormatNumber() function maybe a better choice:
VB Code:
FormatNumber(5000.25, 2) 'will output [B]5,000.25[/B]
Jan 24th, 2006, 11:30 AM
#5
Thread Starter
Fanatic Member
Re: Code for currency field !!!
Originally Posted by
Static
Format(Text3,"#,##0.00")
I am using access database and the field property for "AMT" is "CURRENCY".
Please help.
Attached Images
Jan 24th, 2006, 12:20 PM
#6
New Member
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.
Jan 24th, 2006, 12:34 PM
#7
Re: Code for currency field !!!
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)
Jan 25th, 2006, 03:35 AM
#8
Thread Starter
Fanatic Member
Re: Code for currency field !!!
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.
Jan 25th, 2006, 08:36 AM
#9
Re: [RESOLVED] Code for currency field !!!
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width