Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform Sum field - Please Help!!

Status
Not open for further replies.

vfisher

Programmer
Apr 15, 2002
40
US
I am using Access 97. I have a subform containing a DSum field in the footer. As the user is entering data, the field is calculated - but not until the focus goes to the next row or to the parent form.

I have a "Save" button on the main form which validates the DSum field to a field on the parent. If the user didn't tab to the new record, or go to some other field on the parent, the DSum field is not correct.

I tried setting to focus to a field on the parent form before the validation, but it doesn't force the amount in the last row updated to be added to the DSum field. Is there a way to force the calculation in the DSum field??

Any help will be greatly appreciated.

Thanks
 
Sorry - it's a sum field not a DSum - but I've tried that too!!
 
See if this helps: In your Save button's Click event procedure, refresh the subform before you test the value:
Code:
    <subform control>.Form.Refresh
Maybe that will cause the footer field to be recalculated. Rick Sprague
 
Thanks for the suggestion. If I do the refresh in the click event for the save button, it still doesn't get refreshed before the validation occurs. It appears I'm missing something basic about the order of the events.

I did put a refresh button on the form and this does force the sum, but I can't figure out why that doesn't work in the &quot;Save&quot; button.
 
See if this is what you're looking for. I have done this with a time card data entry system I have written. If you already have an unbound text box set with your subform's calculated field from the footer, then:
In the After Update event of your detail section field that you are summing, put this code:
Code:
Me.Refresh

This will dynamically update the form's field after the detail field from the subform has been changed.
 
Thanks. That works much better. They still have to tab to next field, but at least they don't have to go to a new record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top