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

capture "on close event" on a form

Status
Not open for further replies.

scroce

MIS
Nov 30, 2000
780
US
I'm severly handicapped in excel-ese.

I've created a form and all I want it to do is say, "are you sure you want to close this form?" when someone clicks the "x".

Or I guess I could do something like below a saw on another post here:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
Cancel = True
End If
End Sub


but i'm confused as to where this code gets placed in order for it to execute when someone closes the form - there's no "on close" event or anything like i'm used to in access.

Seek not outside yourself; heaven is within.
 
That code gets placed in the code pane of the userform. Just double click on the form in design view (the VB editor) and then place the code in the window that opens.

A.C
 
when i do that i get:

Private Sub UserForm_Click()

End Sub


just to make sure - is this what i want? it looks like this code will execute when the user clicks the form - I was expecting something like:

Private Sub UserForm_Close()
Seek not outside yourself; heaven is within.
 
scroce,

there should be a couple of drop-down list boxes at the top of the window where you have "Private Sub UserForm_Click()...End Sub".

select "UserForm" from the list box on the left
then select "QueryClose" from the list box on the right
 
ah - i see said the blind man. thanks. Seek not outside yourself; heaven is within.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top