Results 1 to 4 of 4

Thread: Excel Forms

  1. #1
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273

    Unanswered: Excel Forms

    I have a form in Excel that records data, its is an Order Form. On this is a column for Price. I have a number of rows for creating a Description of Goods, Qty & Price. These are all as a Text Box. At the bottom is a Total Box, this is as a Label.

    What I am trying to do is after the Text Boxes have had a value input is to calculate the Total Price as we go along. How do I get this to work?

    This is what I have been doing....
    Code:
    Private Sub txtPrice1_AfterUpdate()
    GetTotal
    End Sub
    Private Sub txtPrice2_AfterUpdate()
    GetTotal
    End Sub
    Private Sub txtPrice3_AfterUpdate()
    GetTotal
    End Sub
    Private Sub txtPrice4_AfterUpdate()
    GetTotal
    End Sub
    Private Sub txtPrice5_AfterUpdate()
    GetTotal
    End Sub
    Code:
    Sub GetTotal()
    TotalPrice.TotalCalc
    Me.lblTotal = TotalPrice.IngTotalPrice
    End Sub
    Code:
    Public IngTotalPrice As Long
    Public TotalPriceCalc As Long
    
    Sub calcTotalPrice()
        If IsNumeric(usrFrmInputPO.txtPrice1) And IsNumeric(usrFrmInputPO.txtPrice2) And IsNumeric(usrFrmInputPO.txtPrice3) And IsNumeric(usrFrmInputPO.txtPrice4) And IsNumeric(usrFrmInputPO.txtPrice5) Then
            TotalCalc
        End If
    End Sub
    
    Sub TotalCalc()
    IngTotalPrice = usrFrmInputPO.txtPrice1 + usrFrmInputPO.txtPrice2 + usrFrmInputPO.txtPrice3 + usrFrmInputPO.txtPrice4 + usrFrmInputPO.txtPrice5
    End Sub
    When I use that it tells me that there is a Type Mismatch as example if I've entered 5.00 or anything like a currency value. If I just enter a whole number like 5 then the lblTotal will still not add them up but just keep putting whatever is in the TextBoxes, eg 55555

  2. #2
    Join Date
    Oct 2003
    Posts
    1,091
    Howdy. "Long" only deals with integers. You need to change it to "Single" or "Double".
    old, slow, and confused
    but at least I'm inconsistent!

    Rich
    (retired Excel 2003 user, 3/28/2008)

    How to ask a question on forums

  3. #3
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    Thanks, I've tried the Single or Double instead of Long and when inputting a Price in the Text Boxes it comes back with Type Mismatch and highlights Sub TotalCalc. I got as far as inputting 2 Price in when the Type Mismatch came up.

    What can that be for?
    Last edited by JezLisle; 06-05-08 at 11:06.

  4. #4
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    I've got a little further with this issue by the help from ExcelForum.com

    Trying to understand the CLNG Function, as never come across it before...

    http://www.excelforum.com/showthread.php?t=646289

Posting Permissions

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