Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing forms - easy one.

Status
Not open for further replies.

scroce

MIS
Nov 30, 2000
780
0
0
US
Lets say i have Form1 and Form2.

I want to do something like:

If form1 gets closed, Then
If form2 is open, then close it also.

In other words, form2 can only be open when form1 is - it dosn't necessarily have to be, but if it is, close it.

Can't be that hard can it?

I'm having trouble determining what properties/methods I can manipulate to make this happen. Any one know?

much obliged,

sC
 
Hi sC,
open form 1 in design view and get properties on it then goto the event tab. Click in the on close event then click on the ... button at the end. Choose code builder and paste this line in between the Private sub and end sub lines.

Code:
DoCmd.Close acForm, "form2", acSavePrompt
All you need to change is the form name (put in place of form2). The acSavePrompt you can leave or change to acSaveNo or acSaveYes depending whether you want it to automatially save changes to form2 when it closes, or not or if you want it to prompt to save changes.

In case you're wondering you don't need to bother checking if form2 is open first, access won't complain if it isn't.
Richard
 
thank you very much. I think I was trying too hard.

sC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top