Consulting

Results 1 to 4 of 4

Thread: Show sum of textboxes in a textbox.

  1. #1

    Show sum of textboxes in a textbox.

    Hi All -

    First time here as a member, though I've learned lots from the site just browsing. Anyway, I have a userform that tracks travel expenses. I have a textbox for mileage, one for mileage rate paid, one for lodging and one for meals. At the moment I have the calculation in a command button called "Add New Record". When the button is clicked, the calculation is executed and the value appears in the "Totals" textbox (txtTotCost).

    My question is: is there a way to make the value appear in the "Totals" textbox before the user hits submit? I have built in a way to edit or delete records after they have been submitted, but it just seems like the right approach to display all of the data prior to submitting.

    At present, I do not have any code in the txtTotCost textbox. Here is the code I have in the "Submit" button:

    txtTotCost.Value = "$" & (Val(Me.txtMileage.Text) * Val(Me.txtRate.Text)) + 
    Val(Me.txtLodging.Value) + Val(Me.txtMeals.Value)
    I appreciate any help you can offer. Thanks.

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    You'd have to put the code for summing the textboxes in each textboxes -change event so as the textbox is changed the total box is updated.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Hi Lloyd. Thanks for the help. Also, I read the article you suggested. I'm pretty new to vba and the forums so I didn't realize that I was cross-posting even with a different issue. I rather thought I was casting my net further afield. But I fully understand and will respect the concern. Thanks for letting me know. I truly did not know I was doing something wrong. I appreciate the heads up.

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    I think you've misread things, that link is ALWAYS in my signature, crossposting is when you post in more than one forum with the same question, so you've done nothing wrong

    Did you manage to resolve your query?
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

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