I have a main form called "Update Order". On this form there are several command buttons which open maintenance forms (vendor, carrier, purchaser, etc). By clicking on one of these buttons, the appropriate subform opens and you can add new information. In order to get this new information into the combo boxes on the main form, I have this code in the close event of the maintenance forms:
DoCmd.SelectObject acForm, "Update Order", 0
DoCmd.GoToControl "VendorID"
DoCmd.Requery "VendorID"
And this works great.
My problem is, these maintenance forms can also be opened from the main menu. When I open them from there and then try and close them it obviously blows up because the "Update Order" form is not currently open. So I know I need some sort of "If" statement to only run the the three lines of code above if the "Update Order" form is also open.
I tried:
***
if forms![update order].IsVisible then
DoCmd.SelectObject acForm, "Update Order", 0
DoCmd.GoToControl "VendorID"
DoCmd.Requery "VendorID"
end if
***
but that didn't do it. I'm sure this is fairly straightforward command as it would seem to be commonplace (because the only other option I can see is maintaining two forms that are exactly the same except for the close event code).
Thanks for any help!
Craig
DoCmd.SelectObject acForm, "Update Order", 0
DoCmd.GoToControl "VendorID"
DoCmd.Requery "VendorID"
And this works great.
My problem is, these maintenance forms can also be opened from the main menu. When I open them from there and then try and close them it obviously blows up because the "Update Order" form is not currently open. So I know I need some sort of "If" statement to only run the the three lines of code above if the "Update Order" form is also open.
I tried:
***
if forms![update order].IsVisible then
DoCmd.SelectObject acForm, "Update Order", 0
DoCmd.GoToControl "VendorID"
DoCmd.Requery "VendorID"
end if
***
but that didn't do it. I'm sure this is fairly straightforward command as it would seem to be commonplace (because the only other option I can see is maintaining two forms that are exactly the same except for the close event code).
Thanks for any help!
Craig