unable to get sum

rehanemis

Registered User.
Local time
Today, 18:56
Joined
Apr 7, 2014
Messages
195
Hi.

I have main form("client Status") which contains information about client order and showing the calculations. The subform is also there for receiving the payment from client. I would like to get the sum of amount received(from sub from) and would like to show it on main form that how much amount received from a client. As payment received from client the form should be updated automatically by showing the sum of amount received.

It is also appreciated if some one give information how to take sum of particular field in subform using vba and storing it in main form field.
Note: the forms are created from tables and there is no unbound field.

Looking forward to your kind responses.

thanks
Rehan
 
Try this:
Create a text box in the footer section of the sub form. Set it's Control Source property to
=Sum([NameOfTextBox])
Change NameOfTexBox to the name of the text box in the detail section of the sub form that holds the data you want to be added up. Give the new text box a meaningful name, something like sfTotal.
Create a text box on the main form. Set it's Control Source property to:
=[NameOfSubFormControl].Form!sfTotal
Change NameOfSubFormControl to the name of your sub form control.
 
Unfortunately, I am unable to get the total in main form. It giving #Name? error.

I have attached two snap shots of my form view so that accurate solution can be proposed.

Thanks
 

Attachments

Please answer the following questions:
1 Do you have a correct total in the footer of the sub form
2 What is the setting of the Name property of the text box that shows the total
3 What is the name of the sub form control. This may not be the same as the name of the form that it displays, so please check this carefully. We need the setting of the Name property of the sub form control.
4 What is the expression being used in the text box on the main form in which the total is to be shown. This will be it's Control Source property.
 
I am not an advance user of ms access so i have attached my database program. The only form relevant is "1-client_status".
I would like to get sum of "amount received" from detail section into main form.

Please view my database.

Thanks a lot.
 

Attachments

Please post a copy of the db in A2003 mdb format
 
Here is m db file. I have just created new one in mdb format. My main form is client_status with detail section.

Thanks
 

Attachments

I have modified your db. I have changed the expression used in the Control Source property of the text box on the main form so it now references the text box in the footer of the sub form. I have also changed the Name property of the text box in the Footer section of the sub form to sfTotal, as I suggested in my earlier post.
 

Attachments

Yes it is working but it didn't saving the total(sum) into table in total_paid field.
 
Yes it is working but it didn't saving the total(sum) into table in total_paid field.
Good. That's as it should be. The result of a calculated control should NOT normally be saved to field in a table. It should recalculated whenever and where ever it is needed.
 
so, Please let me know what you propose. Actually i would like to save it into table also. My main aim to save the calculations into table.
 
so, Please let me know what you propose. Actually i would like to save it into table also. My main aim to save the calculations into table.
I have already stated what I propose in my last post, but I shall repeat:
The result of a calculated control should NOT normally be saved to field in a table. It should recalculated whenever and where ever it is needed.
 

Users who are viewing this thread

Back
Top Bottom