Sum of DataEntry Form

leibale

Active Member
Joined
Sep 12, 2002
Messages
337
I'm Using a SubForm with Dataentry=Yes to type and see only the new records.
in every row in the sub form I write the Number of the row in that batch using:
n=recordset.recordcount+1 (at before update event of the form)
now I want 2 things:
1. After Update, To summarize one of the fields (but only in this batch recordset)
2. to append all the new records to another table, and delete them from the original table

thanks
 
Can I ask why you are adding records to one table, then immediately purging them and writing to a second table instead?

As for summarising, try this:
In the subform, add a texbox to the footer that sums the field you want to add up. Say, for example, =Sum([Extended Price]) where [Extended Price] is a field in the Detail section of the subform. Name the textbox something like txtTotal.

In the main form, create a textbox that grabs the summary value. The expression would be something like
=[MySubformName].Form![txtTotal]

Denis
 
Upvote 0
Can I ask why you are adding records to one table, then immediately purging them and writing to a second table instead?

As for summarising, try this:
In the subform, add a texbox to the footer that sums the field you want to add up. Say, for example, =Sum([Extended Price]) where [Extended Price] is a field in the Detail section of the subform. Name the textbox something like txtTotal.

In the main form, create a textbox that grabs the summary value. The expression would be something like
=[MySubformName].Form![txtTotal]

Denis

Thank you, Denis
I tried Dsum, in which I chk in the criteria section the UserID, and the starting time of Main Form just to be sure I summarize only the new records done by that user.
Of course, The SUM function is better way, it is simple and no need to chk anything
The Dfunctions ignore the batch records and "Look" on all the records in the table
So, If I want to Sum with Criteria, I can SUM an IIF function instead of using Dsum function
=Sum(IIf([Field1=1,[Field2],0)) something like Sumif function in excel
By the way, I tried the Sum Function, and it is good also in the header - isn't it?

About your first question, I wanted the user to write some lines in a consignment, and when he finish, after chking, I'l put the recordes in the main Table. Now I think maybe I do not need it
 
Upvote 0
Yes, Sum is good in the header too.

For totalling subforms I tend to put it in the footer, so but in reports where I'm generating summary reports I often use the section headers.

Denis
 
Upvote 0
Thanks Denis.
What do you think about the concept of writing the records of the sub form for every consignment, into temporary file, and only when every thing is done, to append them to the main table...
 
Upvote 0
I prefer not to do that. You're double-handling the data for no good reason that I can think of. The only time where you need to do something like that is in multi-user setups that use unbound forms; then you need code to load and unload the data.

Denis
 
Upvote 0
I prefer not to do that. You're double-handling the data for no good reason that I can think of. The only time where you need to do something like that is in multi-user setups that use unbound forms; then you need code to load and unload the data.

Denis
Thank you Danis.
Im not sure I understand the sample in which you do recommend the double handling.

How you handle this:
I need a Consignment Form , and sub-form with the lines of the consignment. The user may think that until he do not click on the Save button, the consignment is not Saved and he can cancel. But the moment the user is moving to the sub form, the main record is saved, and also every line in the sub form is also saved immediately. So how to handle it and how I can be sure that this consignment with the records in the sub form are part of the DB only after every thing is checked and the User click on the Save button?
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top