Results 1 to 9 of 9

Thread: [RESOLVED] Code for currency field !!!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Resolved [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.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Code for currency field !!!

    Format(Text3,"#,##0.00")
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Code for currency field !!!

    If you want the comma, use this:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   MsgBox Format(5000.25, "#,#.00")
    5. End Sub

    if not, use this:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   MsgBox Format(5000.25, "#.00")
    5. End Sub

  4. #4

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    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.
    Attached Images Attached Images  

  6. #6
    New Member
    Join Date
    Jan 2006
    Location
    Chennai, India
    Posts
    4

    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.

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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:
    1. Private Sub Text1_Change()
    2.     If IsNumeric(Text1.Text) Then
    3.         Text1.Text = FormatNumber(Text1.Text, 2)
    4.     End If
    5. End Sub
    6.  
    7. 'OR
    8.  
    9. Text1.Text = FormatNumber(rs!AMT, 2)
    10.  
    11. 'OR
    12.  
    13. Text1.Text = FormatNumber(rs.Fields("AMT").Value, 2)

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    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:
    1. Private Sub Text1_Change()
    2.     If IsNumeric(Text1.Text) Then
    3.         Text1.Text = FormatNumber(Text1.Text, 2)
    4.     End If
    5. End Sub
    6.  
    7. 'OR
    8.  
    9. Text1.Text = FormatNumber(rs!AMT, 2)
    10.  
    11. 'OR
    12.  
    13. Text1.Text = FormatNumber(rs.Fields("AMT").Value, 2)

    It works fine. Thanks a lot.

  9. #9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width