+ Reply to Thread
Results 1 to 3 of 3

generating text box value based on equation from other boxes

  1. #1
    Craig
    Guest

    generating text box value based on equation from other boxes

    I've got an invoicing macro that totals 4 amount boxes and a amount
    paid box (input boxes on the form). I'm trying to get the total box to
    update based on the amounts in this box, but i keep getting a type
    mismatch, here's what i have for the change events on the five inpute
    boxes

    Private Sub FirstAmtBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    BalanceDueAmountBox.Value = ((FirstAmtBox.Value * 1) +
    (SecondAmtBox.Value * 1) + _
    (ThirdAmtBox.Value * 1) + (FourthAmtBox.Value * 1) -
    (AmtPaidBox.Value * 1))
    End Sub

    any suggestions?


  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Craig,

    Try this...

    Private Sub FirstAmtBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Dim AmountDue
    AmountDue = CCur(FirstAmtBox.Text ) +
    CCur(SecondAmtBox.Text ) + _
    CCur(ThirdAmtBox.Text ) + CCur(FourthAmtBox.Text) -
    CCur(AmtPaidBox.Text)
    BalanceDueAmountBox.Text = Format(AmountDue, "Currency")
    End Sub

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    05-14-2006
    Posts
    33
    Your code seems to run fine. You might want to check that you have named your textboxes correctly as using a wrong name will cause a new variable to be declared. This new variable will be given the Variant type, causing the type mismatch error.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1