You probably need to take into account the fact that one or more of these items may be Null (empty) so
Code:
= [nameofcontrolwithsubtotal1] + [nameofcontrolwithsubtotal2]
probably should be
Code:
= Nz([nameofcontrolwithsubtotal1], 0) + Nz([nameofcontrolwithsubtotal2], 0)
Having said that, I have to tell you that this is an unusual way of handling this type of situation. The standard way of doing an order/invoice situation would be using a
one-to-many scenario, with the '
one' side being the
Orders and the '
many' side being the
Products. This is usually handled with a
Main Form/
Subform set up.
In general terms the
Main Form would be a
Single View Form and based on a
OrdersTable. The
Subform would probably be a
Datasheet View Form (to better display the 'Products' Field) based on a
Products Table.
The
Fields would typically be something like this:
OrdersTable
OrdersID 'Primary Key
CustomerName
CustomerAddress
...and so forth
ProductsTable
OrdersID 'Foreign Key
ProductsID 'Primary Key
ProductName
ProductPrice
...and so forth
Once you've designed your
OrdersForm and
ProductsForm, based on
OrdersTable and
ProductsTable, respectively, open the
Main Form (
OrdersForm) in
Form Design View and add a
Subform Control to it. The
Subform Wizard will walk you through the process. When asked, base your
Subform on the
ProductsForm. Seeing that both
Tables the
Forms are based on have a
Field named
OrdersID, the
Wizard should ask if you want to link the
Main Form /Subform using these
Fields. Answer
OK and Bob's your uncle!
This would allow for an Order with
one Product or one with
a gazillion Products. You'd place a
Calculated Control on your
Subform to add up the
Product * Price column then have a
Control on the
Main Form with this
Control as its
Control Source.
Linq
;0>