Results 1 to 3 of 3
  1. #1
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25

    Change Currency amount in control

    I searched the old threads and couldn't find an answer so..



    How do I use VBA to change the value of a currency control in my form?

    I use the this code to change number controls. But for a currency control it would put "100" in the control instead of "$100.00".
    Code:
    Me.Control.Value = "100"

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Change the text box property to fixed, instead of currency.

  3. #3
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    Okay that didn't really solve my problem, but I found a solution. What I have a search form based on a query that has the forms controls as criteria, which include min a max currency controls to filter. But if the user leaves a currency blank then I want the form to use a min of $0.00 and a max of $10,000,000.00 so I have VBA enter in the values if the user left those null. However the VBA will put 0 instead of $0.00. And your recommendation does 0.00 instead, which doesn't really help.

    However I found a solution and I thought I would post it for anyone else who might need it. I left the controls as currency, then had vba tell the control to equal "0" (or whatever I want), then in the next line of code would be to add 1, then another line of code to subtract 1. This would then trigger the form to accept those values as currencies. Here is an example of my code.
    Code:
         If IsNull(Me.[txtInvoiceAmountGreater].Value) Then
         [txtInvoiceAmountGreater] = "0.00"
         End If
         If IsNull(Me.[txtInvoiceAmountLessThan].Value) Then
         [txtInvoiceAmountLessThan] = "10000000.00"
         End If
              
         If IsNull(Me.[txtAmountDueGreater].Value) Then
         [txtAmountDueGreater] = "0.00"
         End If
         If IsNull(Me.[txtAmountDueLessThan].Value) Then
         [txtAmountDueLessThan] = "10000000.00"
         End If
         
        'This makes the form register the values as currancy instead of numbers
        [txtInvoiceAmountGreater] = [txtInvoiceAmountGreater] + 1
        [txtInvoiceAmountLessThan] = [txtInvoiceAmountLessThan] + 1
        [txtAmountDueGreater] = [txtAmountDueGreater] + 1
        [txtAmountDueLessThan] = [txtAmountDueLessThan] + 1
        [txtInvoiceAmountGreater] = [txtInvoiceAmountGreater] - 1
        [txtInvoiceAmountLessThan] = [txtInvoiceAmountLessThan] - 1
        [txtAmountDueGreater] = [txtAmountDueGreater] - 1
        [txtAmountDueLessThan] = [txtAmountDueLessThan] - 1

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

Similar Threads

  1. Amount of control of outlook
    By Ruegen in forum Access
    Replies: 6
    Last Post: 12-04-2014, 07:57 PM
  2. Replies: 2
    Last Post: 10-03-2014, 10:07 AM
  3. Replies: 12
    Last Post: 07-18-2014, 01:22 PM
  4. Replies: 6
    Last Post: 11-18-2013, 04:50 PM
  5. Replies: 10
    Last Post: 11-13-2006, 02:07 AM

Tags for this Thread

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