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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close one form from another?

Status
Not open for further replies.

ATAIntern

Programmer
Feb 20, 2001
7
US
Hi, all!

I've been wrestling with this for a bit, with the error messages changing every time I change the code, but nothing's quite working.
I've got three forms open. When I hit a button on Form3, I want it to close itself and Form2 (while first setting a control on Form1).
OK, why doesn't this work?
Code:
Private Sub cmdSelect_Click()
     Forms!Form1!Control1 = Me.Control1
     DoCmd.Close acForm, Form2     
     DoCmd.Close
End Sub

The offending line (closing Form2) gives me an "Object Name required" error at run-time, and changing it to
Code:
DoCmd.Close "Form2"

gives me a type-mismatch error(!?).

Is there an approved way to close a form from another, or something else I'm missing here?
TIA,
ATAIntern:-I
 
These things are rascals sometimes! This should work for you:
DoCmd.Close acForm, "Form2"
!
Gord
ghubbell@total.net
 
Yep, that's got it.

Thanks, Gord!

I'll be ba-ack...many more things puzzling me, going to try to get as far as I can on my own first.

ATAInterns-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top