John:
I'm sure I'm reaching the point of aggravation, but I have referred to every
possible fieldname possible on this Subform for subtotal, and nothing comes
up but $0.00 or Error.
I think I figured out the issue.
When I enter a mock-order, in the "Order Details Services" subform Dataview,
the the Order ID; Product Name; and Price show up. The prices show up
because I created a combo box to find the price in column2 of the Product
Name in creation of the form. However, the prices don't show in the Orders
table despite the rest do.
Of course the prices don't - and shouldn't - show up in the Orders
table. A price refers TO AN ITEM, not to an order as a whole. If you
want to calculate a total price for an order, calculate it on the fly,
as needed - DON'T store it in the table.
In the Order Details table, the Order ID and
Product Name shows up, but nothing shows up under the Price column except
$0.00. I believe my sum is working correctly in refering to price, but there
aren't prices to sum, so it comes up $0.00. Any ideas on correcting this?
Since a) prices can change over time (they usually go up, except in
the computer area <g>) and b) you want to record the price *as of the
time that an order was purchased*, you really should have a Price
field in BOTH the Item table *and* in the OrderDetails table.
You can copy the (current) price from the Items table into the
OrderDetails table with a little bit of VBA code in the AfterUpdate
event of the item combo box. Open the product name combo box - I'll
call it cboProducts, since I don't like blanks in object names and
don't like Access' convention of using the fieldname as the control
name - in design view. On the combo's Properties Events tab click the
.... icon by the AfterUpdate property, and choose Code Builder; edit
the code to something like
Private Sub cboProducts_AfterUpdate()
Me.txtPrice = Me.cboProducts.Column(2)
End Sub
to "push" the price from the third column of the combo box into the
bound Price control (named txtPrice).
John W. Vinson[MVP]