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

When Form is closed, not close only hide

Status
Not open for further replies.

jdrawmer

Programmer
Dec 1, 2006
25
GB
this may be very simple, and i'm sure it should be... but when the 'x' button is pressed, i don't want the form to unload completely, i just want it to hide... And its really not happening for me!

Any help would be appreciated. Thanks!
 
This may do it;

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

If UnloadMode = vbFormControlMenu Then
Cancel = True
Me.Hide
End If

End Sub
 
My previous assumed vb6 but you require VBA so;

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode = vbFormControlMenu Then
Cancel = True
Me.Hide
End If


End Sub
 
i'm sorry, but it doesn't seem to do very much. Do i have to trigger this sub with anything when the form is deactivated or anything? Its not the end of hte world if i can't do this, but it would make the system a lot more user friendly

Thanks a lot
 
Never mind just got your second reply, that worked a treat! thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top