total

G

Guest

I have a form called customer. In the customer form there
is a field called 'Total No of Gloves'. In the customer
form their a sub form 'workorder'. In the workorder
subform there is field called 'No of gloves'.

I want to display the total from subform (workorder)
field 'No of gloves' in the field 'Total No of Gloves' of
the form customer and store the value in database

i am attaching database.
 
D

Dirk Goldgar

I have a form called customer. In the customer form there
is a field called 'Total No of Gloves'. In the customer
form their a sub form 'workorder'. In the workorder
subform there is field called 'No of gloves'.

I want to display the total from subform (workorder)
field 'No of gloves' in the field 'Total No of Gloves' of
the form customer and store the value in database

i am attaching database.

Fortunately you did *not* attach the database. That's frowned on in
these text newsgroups.

Why do you want to store the calculated value from the subform in the
database? That's not normally a good idea. There are all kinds of ways
the Workorder details could be changed outside of the form and subform
you've designed, and then that field in the Customer table would be
wrong. But the total number of gloves for the customer can be
calculated at any time.

I'd recommend instead that you delete the [Total No of Gloves] field
from the Customer table, and set the controlsource of the text box
"Total No of Gloves" to an expression that simply pulls the value from
the subform, or else uses the DSum() function to get it directly from
the Workorder table. I prefer the former approach. Here's how you do
it:

If you don't already have a form header or form footer section on the
subform, add one. If you don't want the user to actually see this
section, set Visible property on its property sheet to No. Add a text
box to that section, name it "txtTotalGloves", and set its controlsource
to

=Sum([[No of gloves])

If you've put this text box on a Visible section, but don't want the
text box itself to be visible, set its Visible property to No.

Now, on the main form, set the controlsource of the [Total No of Gloves]
text box an expression like this:

=[Workorders]![txtTotalGloves]

In the above expression, "Workorders" must be the name of the subform
control on the main form, which may or may not be the name of the form
object that control is displaying.

That ought to do it. Please post back if you have any problems or
questions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top