I have a form with a frame. i want to close form with Esc Key and i m doing this. But when frame is visible then it should hide frame but its closing form. Is there any way to hide frame when frame is visible with Esc Key and close form when frame is hidden.

i am using this.

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then
If frm1.Visible = True Then
frm1.Visible = False
Else
Unload Me
End If
End If
End Sub

Any other ways to do this.?