• Recalculating textbox on main form

    Author
    Topic
    #461536

    I have TransactionForm (main) on which resides DonationMain and DonationDetails. DonationDetails is synched to DonationMain and changes as you move from record to record in DonationMain.

    DonationMain is continuous forms.

    On the TransactionForm, there is a calculated textbox txtTotal which is updated via a custom function ttl(). This all works fine if you are entering new records into the database.

    Today I noticed, as you move from record to record on DonationMain, that txtTotal was not recalculating so it was always showing the total for the first record in DonationMain.

    I’m not sure of what syntax I need to use or where I need to use it on DonationMain to force the function ttl() to recalculate whenever a new record on DonationMain is selected. If I stick something into the OnCurrent event of DonationMain, it starts recalculating over and over (presumably because the combo box that displays names has to recalculate as the form is drawn, an unfortunate necessity due to legacy issues in the design). Of tried GotFocus and various other ideas but this one has me stumped now.

    Viewing 0 reply threads
    Author
    Replies
    • #1171474

      The On Current event procedure of DonationMain would be the place to recalculate the text box. If that causes problems, we’d have to know more about the code you’re using. Without having any information it’s impossible to provide recommendations.

      • #1171475

        The On Current event procedure of DonationMain would be the place to recalculate the text box. If that causes problems, we’d have to know more about the code you’re using. Without having any information it’s impossible to provide recommendations.

        Maybe my syntax was wrong. I’m not at that location now, but I believe I was trying Me.Parent.Recalc I also tried specifying the actual textbox. I can’t remember what I used for that.

        • #1171476

          Me.Parent.Recalc would be the first thing I’d try, but that will recalculate all calculated controls on the parent form.

          As an alternative, you might clear the control source of txtTotal, and set its value in the On Current event of DonationMain.

          • #1171711

            Me.Parent.Recalc would be the first thing I’d try, but that will recalculate all calculated controls on the parent form.

            As an alternative, you might clear the control source of txtTotal, and set its value in the On Current event of DonationMain.

            I got it. I use the recordset.clone method to make sure there are some records in donationMain before I requery the function. It now only runs if there is data and recalculates properly when you switch records. There is a very complicated query for a lookup box in donation Main that is slow to run and it is now being forced to run when you switch records, but it is acceptable. It’s actually still a lot quicker than just about anything running in Vista…

            Thanks for confirming yet again that I was looking in the right direction, just not quite right enough!

    Viewing 0 reply threads
    Reply To: Recalculating textbox on main form

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: