That response mostly just confused me more…
Jordan_Davis1:
the customers can only remove or modify existing records in the child table, they can’t add records
I can’t imagine how you expect this to work here then.
Going in a different direction, I’ll explain how I would set this up to meet what I think your requirements are, within your described app functionality.
Have 2 Tables:
- Purchase Order (“fruit basket”)
- PO Line Item (“fruit” ?)
Purchase Order can be thought of just as a “folder” for the individual Line Items, but will also hold our total price, as well as reference to a Customer if need be.
Each Line Item will reference a single fruit, with a valid_if that you cannot select the same fruit twice within the same PO. You’ll also enter a quantity, and have a sub-total calculated out. IN this calculation here is where you’ll use the $150 max, it could just be:
MIN( $150 , [qty] * [fruit].[price] )
Your PO total price will be:
SUM( [Related Line Items][subtotal] )
Or, I wasn’t sure if the $150 cap was supposed to be applied over the entire PO, or not (that would seem like an amazing deal if so, so I’d doubt it, but just in case…). If so, add a Yes/No column in your Line Item Table, titled something like “Deal Reached?”, with expression:
[qty] * [fruit].[price] > 150
Then change the PO’s total calculation expression to:
IF(
IN( TRUE , [Related Line Items][Deal Reached? ) ,
150 ,
SUM( [Related Line Items][subtotal] )
)
Note that I’m working with just total prices, as I assumed from the first post, but you just explained further that you’re wanting price per item. Not sure why that wasn’t mentioned from the beginning, or at what level exactly you’re looking for that, but hopefully you can use the above to figure out how to meet the needs of your situation, and change as needed.