How to close the result window with ESC

  • Thread starter Thread starter naveen prasad
  • Start date Start date
N

naveen prasad

Hi

in the form, a command button executes a query when clicked.

I want to close the result window with ESC key press in the keyboard.

i dont want to click on the close of that window.

pls help me if it is possible and how can i do it.
 
Hi

in the form, a command button executes a query when clicked.

I want to close the result window with ESC key press in the keyboard.

i dont want to click on the close of that window.

pls help me if it is possible and how can i do it.

You can't. If you're opening a query and not a form, you cannot trap
for any events. You can close any window inside Access by using CTRL-
F4 while the object has focus.
 
Is it possible if we create form based on query,

then can we close with esc keypress to close form ??
 
wow excellent it really worked....

thank you very much .....:)




PieterLinden via AccessMonster.com said:
naveen said:
Is it possible if we create form based on query,

then can we close with esc keypress to close form ??
On Jan 30, 12:39 pm, naveen prasad
<[email protected]> wrote:
[quoted text clipped - 12 lines]
F4 while the object has focus.
.

Open the form in design view and set the KeyPreview property of the form to
True.

Then add this code to the form's code module:

Private Sub Form_KeyPress(KeyAscii As Integer)
'NOTE: this is a really weird use of ESC!!!
' Some users may find this confusing!!!

Const ESC_KEY As Integer = 27

If KeyAscii = ESC_KEY Then
DoCmd.Close acForm, Me.Name
End If

End Sub
 
Back
Top