Need to close mulitple forms

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
0
Utf
5/13/2010 10:16:01 PM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
969 Views

Similar Articles

[PageSpeed] 1

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@discussions.microsoft.com> wrote in message 
news:2502521E-01D6-4AC3-B6B8-329914B123EF@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 

0
Douglas
5/13/2010 11:40:52 PM
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

0
Linq
5/14/2010 12:05:26 AM
Reply:

Similar Artilces: