On close, call a procedure that exists in another open form

  • Thread starter Thread starter JimS
  • Start date Start date
J

JimS

I have an orders form with a subform that lists the "kits" that make up the
order. The customer may purchase one or more kits per order. The user
selects the kit from a combo box on the subform and enters a quantity in a
textbox. The order is then priced based on the cost of the kit and the
quantity ordered.

This works fine.

The wrinkle is that the kits are priced based on the parts they contain and
the kit contents can be changed. So on the subform next to the kit combobox
is a command button that allows the user to do this. The user clicks on the
command button and up pops the kit form. The user can then add or delete
parts in the kit as required.

The problem is that when I close the kit form I need to update my order
form. Specifically, I need to update the price of the order based on the
new kit contents. The functionality for updating the price of the order is
currently contained in the AfterUpdate event procedure of the quantity
textbox on the subform.

How can I call this procedure after I close my kit form?
 
Thanks Arvin

Unfortunately, a requery will not work in this case. The functionality for
updating the price of the order that is contained in the AfterUpdate event
procedure contains ADO code to do a delete followed by an insert. The
requery will update the underlying data but it will not fire the AfterUpdate
event I need to trigger the ADO code.

I am looking for a way to call the AfterUpdate function after the popup
window closes and returns focus to the orders form.
 
Jim,

How about something like this ---

Put the following code in the Click event of your button:
DoCmd.OpenForm "KitForm",,,,,acDialog
Me!MyFormField = Forms!KitForm!Somefield
<<Your ADO code >>
DoCmd.Close acForm, "KitForm"

After you do whatever you do in the KitForm, make the form invisible, don't
close it. You can then pass data from the Kit form as I show in the example
above.
 
Back
Top