I have a order entry system that performs a long list of multiplications (most of which are n x 0) to result in quantities of items ordered. It is long because each item applies to 10 possible variations of a product.
To clarify a little here's an example; An 'Ashley seat' is the same across the range, needing 1 per 'chair', 2 per '2seater' and 3 per '3seater'. The other 7 variations on this product are blank, so it multiplies by 0 for those. The expression for this worked fine, but now needs to expand and allow the option of 'Complete', 'Trim only' or 'Seats only'.
So the formula is:
**edit: I've put in a load of carraige returns to make the formula a bit clearer to read.**
Qty: IIf([Forms]![frmChooseAProductForOrder]![opgComplete]=1,
[Forms]![frmChooseAProductForOrder]![AOrders]*[tblMainTable]![QtyPerA]+
[Forms]![frmChooseAProductForOrder]![BOrders]*[tblMainTable]![QtyPerB]+
[Forms]![frmChooseAProductForOrder]![COrders]*[tblMainTable]![QtyPerC]+
[Forms]![frmChooseAProductForOrder]![DOrders]*[tblMainTable]![QtyPerD]+
[Forms]![frmChooseAProductForOrder]![EOrders]*[tblMainTable]![QtyPerE]+
[Forms]![frmChooseAProductForOrder]![FOrders]*[tblMainTable]![QtyPerF]+
[Forms]![frmChooseAProductForOrder]![GOrders]*[tblMainTable]![QtyPerG]+
[Forms]![frmChooseAProductForOrder]![HOrders]*[tblMainTable]![QtyPerH]+
[Forms]![frmChooseAProductForOrder]![IOrders]*[tblMainTable]![QtyPerI]+
[Forms]![frmChooseAProductForOrder]![JOrders]*[tblMainTable]![QJtyPer],
IIf([Forms]![frmChooseAProductForOrder]![opgComplete]=2,IIf([tblMainTable]![S/T?]="Trim",
[Forms]![frmChooseAProductForOrder]![AOrders]*[tblMainTable]![QtyPerA]+
[Forms]![frmChooseAProductForOrder]![BOrders]*[tblMainTable]![QtyPerB]+
[Forms]![frmChooseAProductForOrder]![COrders]*[tblMainTable]![QtyPerC]+
[Forms]![frmChooseAProductForOrder]![DOrders]*[tblMainTable]![QtyPerD]+
[Forms]![frmChooseAProductForOrder]![EOrders]*[tblMainTable]![QtyPerE]+
[Forms]![frmChooseAProductForOrder]![FOrders]*[tblMainTable]![QtyPerF]+
[Forms]![frmChooseAProductForOrder]![GOrders]*[tblMainTable]![QtyPerG]+
[Forms]![frmChooseAProductForOrder]![HOrders]*[tblMainTable]![QtyPerH]+
[Forms]![frmChooseAProductForOrder]![IOrders]*[tblMainTable]![QtyPerI]+
[Forms]![frmChooseAProductForOrder]![JOrders]*[tblMainTable]![QtyPerJ],
IIf([Forms]![frmChooseAProductForOrder]![opgComplete]=3,IIf([tblMainTable]![S/T?]="Seats",
[Forms]![frmChooseAProductForOrder]![AOrders]*[tblMainTable]![QtyPerA]+
[Forms]![frmChooseAProductForOrder]![BOrders]*[tblMainTable]![QtyPerB]+
[Forms]![frmChooseAProductForOrder]![COrders]*[tblMainTable]![QtyPerC]+
[Forms]![frmChooseAProductForOrder]![DOrders]*[tblMainTable]![QtyPerD]+
[Forms]![frmChooseAProductForOrder]![EOrders]*[tblMainTable]![QtyPerE]+
[Forms]![frmChooseAProductForOrder]![FOrders]*[tblMainTable]![QtyPerF]+
[Forms]![frmChooseAProductForOrder]![GOrders]*[tblMainTable]![QtyPerG]+
[Forms]![frmChooseAProductForOrder]![HOrders]*[tblMainTable]![QtyPerH]+
[Forms]![frmChooseAProductForOrder]![IOrders]*[tblMainTable]![QtyPerI]+
[Forms]![frmChooseAProductForOrder]![JOrders]*[tblMainTable]![QtyPerJ],0),0))),0))
But it is way too long. I tried changing everything that gets referenced to shorter names (tMT --> tblMainTable for example) but this not only isn't ideal but also was still too long!
Is there a different approach I can use for this? Especially as it will also need to do the same expression with 2, 3 etc after all the [nOrders] and [opgComplete]s for the other products on the same order because it runs 9 separate Append Queries, one for each product on an order, to append to tblOrders and then run a select query which collates everything with the Order Number that was assigned to this order.
PS Let me know if anything isn't clear.
PPS I believe that longer expressions can be done in VBA but I don't know where I put this code and how it becomes 'attached' to my forms/queries/whatever.