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!

stop form from closing with Esc key

Status
Not open for further replies.

WebStar

Programmer
May 1, 2002
69
DE
Hi there,
I have a problem: I have a form that has on it only a label and an progress bar. When I need the progress bar the form shows and the bar starts working... but the problem is that by pressing the Esc key the form closes. How can I stop this? Thank you!
 
If Access then, In the forms keydown event...


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyEscape Then exit sub

End Sub



 
Ooops forget 1 major thing...

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyEscape Then keycode = 0 : exit sub

End Sub
 
See the form's procedures - something like UserForm_Key??? ?
If not, select the form in VB Editor and check for commandbuttons in the properties window's drop-down list. Maybe there is a very small one or sits otside the visible form's area (resize form to check), with 'Cancel' property set to 'True'...

combo
 
there was no function for key pressing and there is no hidden button. I've just created the form. The interesting thing is that my colegue here made the same form and is not closing at Esc press.
Now I've tried the key_down event described abouve by ETID but is not even raised. When I press the ESC key the form closes and the key_down event is not raised. Here is the entire code from my form:
Code:
Public mode As Integer
Private Sub UserForm_Activate()
Dim newHour As Integer, newMinute As Integer, newSecond As Integer
Dim waitTime As Date
If mode = 1 Then
    Update.Process.Caption = "WP will search if there is new data to import!"
    If Not TransferDatabase.GetData Then
        Process.Caption = "There was an error updateing data!"
        newHour = Hour(Now())
        newMinute = Minute(Now())
        newSecond = Second(Now()) + 3
        waitTime = TimeSerial(newHour, newMinute, newSecond)
        Application.Wait waitTime
    End If
End If
If mode = 2 Then
    modules.OpenProject
End If
End Sub

Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = vbKeyEscape Then KeyCode = 0: Exit Sub
End Sub
[\code]
 
If your colegue "imports" your form, do you get repeat symptoms?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top