From: Iram on
Hello,
I need help writing code to close two forms at the click of a button. I have
the below code but it keeps erroring out.
I want to close a form called "frm_AddtlToolsCasesUIBAll" and the current
form that I am on/the form that has the button to close both forms.

How should I rewrite this?

Private Sub Command87_Click()
Dim frm_theOtherForm As Form

Set frm_theOtherForm = Forms![frm_AddtlToolsCasesUIBAll].Form
frm_theOtherForm.Close
Set frm_theOtherForm = Nothing

DoCmd.Close

End Sub


Your help is greatly appreciated.

Thanks.
Iram
From: Douglas J. Steele on
Setting a reference to the form isn't what you want.

All you need is

Private Sub Command87_Click()

DoCmd.Close acForm, "frm_AddtlToolsCasesUIBAll"
DoCmd.Close acForm, Me.Name

End Sub


--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/djsteele
(no e-mails, please!)



"Iram" <Iram(a)discussions.microsoft.com> wrote in message
news:2502521E-01D6-4AC3-B6B8-329914B123EF(a)microsoft.com...
> Hello,
> I need help writing code to close two forms at the click of a button. I
> have
> the below code but it keeps erroring out.
> I want to close a form called "frm_AddtlToolsCasesUIBAll" and the current
> form that I am on/the form that has the button to close both forms.
>
> How should I rewrite this?
>
> Private Sub Command87_Click()
> Dim frm_theOtherForm As Form
>
> Set frm_theOtherForm = Forms![frm_AddtlToolsCasesUIBAll].Form
> frm_theOtherForm.Close
> Set frm_theOtherForm = Nothing
>
> DoCmd.Close
>
> End Sub
>
>
> Your help is greatly appreciated.
>
> Thanks.
> Iram

From: Linq Adams via AccessMonster.com on
Not sure what's causing your problem, but I think you're over complicating
this. This should work just fine:

Private Sub Command87_Click()
DoCmd.Close acForm, "frm_AddtlToolsCasesUIBAll"
DoCmd.Close
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201005/1