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

How do I create a form object 1

Status
Not open for further replies.

MalekTaus

Programmer
Nov 5, 2007
10
US
I am trying to create a sub procedure for cancel buttons across several forms.

The problem is that I need to be able to pass the form object to the procedure in order to unload the form.

Can anyone help?
 



Hi,

Check out the Forms collection.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
It was UserForm that I needed.

Thanks for the help and here is my oh so simple solution

Code:
Private Sub btnCancel_Click()
Call cancelButton(Me)
End Sub

Code:
Sub cancelButton(frm As UserForm)

Unload frm

End Sub
 
Form1.Show & Form1.Hide work for me - that way I can set values before it is visible. Or use the Activate/deactivate events to set things up.
 
As long as you do not want to interact with the form you try to close, without calling external procedure:
Code:
Private Sub btnCancel_Click()
Unload Me
End Sub


combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top