Close pop-up together with main form?

C

CW

I have made a popup that displays the various contact persons at each
customer, fired by a button on the main customer form. So far so good.
I want it to close automatically when the customer form itself is closed -
at the moment it stays open and has to be closed separately using its own
close button.
The customer form has a close command button so presumably I can embed some
code in that event to handle this? The event already includes "DoCmd.Close"
so should I add something immediately after that? And if the popup form is
called CustomerContacts, what would the syntax be? (By the way it's not a
subform, just a popup).
Many thanks
CW
 
D

Dirk Goldgar

CW said:
I have made a popup that displays the various contact persons at each
customer, fired by a button on the main customer form. So far so good.
I want it to close automatically when the customer form itself is closed -
at the moment it stays open and has to be closed separately using its own
close button.
The customer form has a close command button so presumably I can embed
some
code in that event to handle this? The event already includes
"DoCmd.Close"
so should I add something immediately after that? And if the popup form is
called CustomerContacts, what would the syntax be? (By the way it's not a
subform, just a popup).


It's probably easiest to just code the customer form's Close event:

'----- start of example code -----
Private Sub Form_Close()

DoCmd.Close acForm, "CustomerContacts", acSaveNo

End Sub
'----- end of example code -----

You don't even have to check first to see if the CustomerContacts form is
open -- if it's not, closing it via DoCmd.Close won't raise any error.
 
C

CW

Dirk -
Perfect, worked a treat
Many thanks
CW

Dirk Goldgar said:
It's probably easiest to just code the customer form's Close event:

'----- start of example code -----
Private Sub Form_Close()

DoCmd.Close acForm, "CustomerContacts", acSaveNo

End Sub
'----- end of example code -----

You don't even have to check first to see if the CustomerContacts form is
open -- if it's not, closing it via DoCmd.Close won't raise any error.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top