Hey,
I have a form Orders with a subform OrderItems. The Orders form is linked to the OrderItems subform by OrderID. The Orders form corresponds to an Orders table, and OrderItems form to an OrderItems table. (one to many join on OrderID).
Each OrderItems record represents one item that can be shipped in an order. It has a field 'NoInStock'. Now, on the subform I want to have a textbox that will allow the user to enter the number of those items sent in the order, and have the database subtract that number from the value of the 'NoInStock' field of that particular OrderItems record.
I thought of doing this with VBA using the 'LostFocus' event (so it would subtract when the user had finished editing), but really this isn't ideal, as the user could select/deselect the textbox and thereby subtract the value many times, or simply edit the field, and the number would be re-subtracted. The database would also pop up that edit records confirmation dialogue each time.
I want it to subtract the value when the user finishes with that particular page on the main form, and hence begins a new Order record, so that edits to the textboxes cannot mess the subtraction up.
Can this be done?
I have a form Orders with a subform OrderItems. The Orders form is linked to the OrderItems subform by OrderID. The Orders form corresponds to an Orders table, and OrderItems form to an OrderItems table. (one to many join on OrderID).
Each OrderItems record represents one item that can be shipped in an order. It has a field 'NoInStock'. Now, on the subform I want to have a textbox that will allow the user to enter the number of those items sent in the order, and have the database subtract that number from the value of the 'NoInStock' field of that particular OrderItems record.
I thought of doing this with VBA using the 'LostFocus' event (so it would subtract when the user had finished editing), but really this isn't ideal, as the user could select/deselect the textbox and thereby subtract the value many times, or simply edit the field, and the number would be re-subtracted. The database would also pop up that edit records confirmation dialogue each time.
I want it to subtract the value when the user finishes with that particular page on the main form, and hence begins a new Order record, so that edits to the textboxes cannot mess the subtraction up.
Can this be done?