Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Fields won't add (2002)

    Hi!

    I have frmPayment with lstInvoice. There are 4 controls on the form that should fill with the data from lstInvoice when the user clicks cmdCalc. This all works fine. My first problem was the that text box controls need to format at currency and when I chose that in the parameters it didn't work. So in the the query that lstInvoice is bound to, I formatted the data as =format([xyz data]),"currency"). This worked fine both in the appearance of the data in the list as well as in the 4 controls. My problem is that when I go to add the controls together in control txtcreditbalance I get #error. I made sure it wasn't a typo which is wasn't. I even tried setting up four new controls that equal the original controls and when I add those I get get a result that shows them as if it was a string of text vs an answer. I'm clueless at this point.

    Thanks,
    Leesha

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Fields won't add (2002)

    The result of the Format function is a text value, not a number value. You cannot add text values, at least not directly.

    How do you populate the four controls? Does your code set their values, or do they have a control source that refers to the list box?

  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Fields won't add (2002)

    Hi Hans,

    I do it with code based on an answer the user selects. Right now the code reads:

    'Fills in fields based on payment reason

    If Me.Payment_Reason = 1 Then

    Me.txtWalmartFee = Me.lstInvoice.Column(1)
    Me.txtTTTSMFee = Me.lstInvoice.Column(2)
    Me.txtSalesTax = Me.lstInvoice.Column(3)
    Me.txtLocalTax = Me.lstInvoice.Column(4)

    Else:

    Me.txtWalmartFee = Null
    Me.txtTTTSMFee = Null
    Me.txtSalesTax = Null
    Me.txtLocalTax = Null
    Me.Invoice_ = Null

    End If

    Leesha

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Fields won't add (2002)

    Try the following:

    - Remove the Format function from the query that acts as row source for lstInvoice. In other words, use the original fields.
    - Change your code to look like this:

    Me.txtWalmartFee = CCur(Me.lstInvoice.Column(1))

    - Similar for the other three.
    - Set the Format property of txtWalmartFee etc. to Currency.

    You should now be able to add the values of the controls.

  5. #5
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Fields won't add (2002)

    Thanks Hans! That did the trick. I can't tell you how many hours I spent trying to get this to work but didn't post it as I figured it had to be a no brainer I was missing! Now you must know me well enough by now to know I need to "understand' what I did. the Ccur - I "assume" means change to currency?

    Leesha

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Fields won't add (2002)

    CCur is one of a group of conversion functions; the name stands for Convert to Currency. It converts a value (which can be a number or string) to a currency value if possible. Examples of other conversion functions are CDate (convert to date), CLng (convert to long integer) and CStr (convert to string). Type any of these in the Visual Basic Editor and press F1 for help.

  7. #7
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Fields won't add (2002)

    Thanks Hans! I'll read up on those. I've used Cdate before based on your help but thought it stood for "change" date and didn't realize there were more.

    Leesha

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Fields won't add (2002)

    "Change" or "convert" - both are appropriate, so it doesn't really matter. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

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