Have posted this one before but no responses and I'm having a real 'mare with it!
I have a form holding contact information which has a subform which displays orders. This orders subform has it's own subform which displays order details. What I want to do is set the value of the field [MainForm]![OrdersSubform].Form![TotalOrderValue] to equal the sum of all the instances of [MainForm]![OrdersSubform].Form![OrderDetailSubform].Form![ItemValue] for that particular order (grouped by [MainForm]![OrdersSubform].Form![OrderID]). In most cases there is just one item in the order but occasionally the number of items can be up to 10.
The problem I have is that [Form]![OrdersSubform].Form![OrderDetailSubform].Form![ItemValue] is actually a calculated control ([Quantity]*[UnitPrice] set via a macro attached to the after update event of [UnitPrice]). So when the macro runs [ItemValue] is updated but the after update event is not triggered. I have tried to run a procedure from the field's on change event but this doesn't seem to work either.
At the moment what I'm having to do is use a query to find the sum of [ItemValue] for each order, then making a table from that query and then basing an update query on that table (I'm having to go through this rigmarole twice a week at the minute).
My skill level with VBA is pretty basic and I have trouble writing anything other than simple procedures - can anyone help me out with some code I can steal!? x-) Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to
produce bigger and better idiots. So far, the Universe is winning.
I have a form holding contact information which has a subform which displays orders. This orders subform has it's own subform which displays order details. What I want to do is set the value of the field [MainForm]![OrdersSubform].Form![TotalOrderValue] to equal the sum of all the instances of [MainForm]![OrdersSubform].Form![OrderDetailSubform].Form![ItemValue] for that particular order (grouped by [MainForm]![OrdersSubform].Form![OrderID]). In most cases there is just one item in the order but occasionally the number of items can be up to 10.
The problem I have is that [Form]![OrdersSubform].Form![OrderDetailSubform].Form![ItemValue] is actually a calculated control ([Quantity]*[UnitPrice] set via a macro attached to the after update event of [UnitPrice]). So when the macro runs [ItemValue] is updated but the after update event is not triggered. I have tried to run a procedure from the field's on change event but this doesn't seem to work either.
At the moment what I'm having to do is use a query to find the sum of [ItemValue] for each order, then making a table from that query and then basing an update query on that table (I'm having to go through this rigmarole twice a week at the minute).
My skill level with VBA is pretty basic and I have trouble writing anything other than simple procedures - can anyone help me out with some code I can steal!? x-) Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to
produce bigger and better idiots. So far, the Universe is winning.