Results 1 to 9 of 9
  1. #1
    Lupson2011 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    68

    formatting a field to be currency in VBA

    Hi all,



    I am writing some code where I am displaying certain information in a list dependent on a choice from a combo box.

    It all works fine, but a couple of the fields are currency format and I wondered if there was anything easy I could add to the line of code below which wold ensure that it is displayed in currency and not just number, or do I have to different lines of code for this?



    Code:
    Me.lstProjectDetails.AddItem "Change Awarded;" & rstqryAssignmentDetails.Fields("AmountAwarded")
    thanks

    marc

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Maybe something like:

    Me.lstProjectDetails.AddItem "Change Awarded;" & Format(rstqryAssignmentDetails.Fields("AmountAward ed"),"$0.00")

    Edit: Ignore the space in the word "AmountAward ed". I am not sure why it is doing that. I copied your formula, and when I edit it, it shows no space, but it appears there after posting.

  3. #3
    Lupson2011 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    68
    Thanks sorted!

    Marc

    Quote Originally Posted by JoeM View Post
    Maybe something like:

    Me.lstProjectDetails.AddItem "Change Awarded;" & Format(rstqryAssignmentDetails.Fields("AmountAward ed"),"$0.00")

    Edit: Ignore the space in the word "AmountAward ed". I am not sure why it is doing that. I copied your formula, and when I edit it, it shows no space, but it appears there after posting.

  4. #4
    Lupson2011 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    68
    JoeM

    Sorry, I know its solved but one more thing. I am trying to get 1000 separator in there as well, but without success. Any help?

  5. #5
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try this structure:
    Format(FieldName,"$0,000.00")

  6. #6
    Lupson2011 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    68
    Hi, I tried that

    Code:
    Me.lstProjectDetails.AddItem "Change Awarded;" & Format(rstqryAssignmentDetails.Fields("AmountAwarded"), "£0,000.00")
    It came up with just a two number format £67, when it should be £67,000.00

    Did I code it right?

    Thanks

    Marc

    Quote Originally Posted by Lupson2011 View Post
    Hi all,

    I am writing some code where I am displaying certain information in a list dependent on a choice from a combo box.

    It all works fine, but a couple of the fields are currency format and I wondered if there was anything easy I could add to the line of code below which wold ensure that it is displayed in currency and not just number, or do I have to different lines of code for this?



    Code:
    Me.lstProjectDetails.AddItem "Change Awarded;" & rstqryAssignmentDetails.Fields("AmountAwarded")
    thanks

    marc

  7. #7
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Is this value that is stored in your AmountsAwarded field 67 or 67000?
    If it is 67, and you want to return 67000 (in whatever format you desire), then multiply by 1000 first before applying the formatting.

  8. #8
    Lupson2011 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    68
    hi

    It is 67000, but for some reason as soon I put in a comma separator, it changes it from 67000.00 to 67..cant work out why?

    Quote Originally Posted by JoeM View Post
    Is this value that is stored in your AmountsAwarded field 67 or 67000?
    If it is 67, and you want to return 67000 (in whatever format you desire), then multiply by 1000 first before applying the formatting.

  9. #9
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    It might have something to do with your Regional Settings. See here: http://support.microsoft.com/kb/142009

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 01-03-2012, 06:54 PM
  2. Replies: 5
    Last Post: 12-10-2011, 11:49 AM
  3. Access export currency field to XML
    By pfarnell in forum Import/Export Data
    Replies: 1
    Last Post: 11-29-2011, 01:46 PM
  4. Replies: 2
    Last Post: 03-23-2011, 11:43 AM
  5. HELP! formatting currency
    By jgelpi16 in forum Reports
    Replies: 1
    Last Post: 07-06-2010, 09:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums