press any key to close

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

Hi,

I created a splash screen and I want it to close when the user press on the
keyboard.
I tried to do it with on key press but it didnt work.

Private Sub Form_KeyPress(KeyAscii As Integer)
DoCmd.Close
End Sub


Thanks,

Ron
 
Hi Ron,

look here


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
Hi and thank you.
This link is broken, I can not find the server.
I did key preveiw yes, It didnt help.

Any other idea?


Thanks for the help,
Ron
 
Hi again,
If any key is not possible, I would to use Space as key to close the form,
but I`m not sure how to do it.
I know that usually fro splash screen the on Timer event is use, but in this
case I need a key stroke.
Thanks for any input on the subject,

Ron
 
Ron said:
Hi and thank you.
This link is broken, I can not find the server.
I did key preveiw yes, It didnt help.

With the form's KeyPreview property set to Yes, this works for me:

Private Sub Form_KeyPress(KeyAscii As Integer)
KeyAscii = 0
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

But the form has to have the focus at the time; otherwise it doesn't see
the keystroke. Are you sure that your form has the focus?

Another possible reason for it not working is that you're doing
something in code, and there's a loop running that doesn't allow Access
to check for the keystroke. If that's the case, you need to put a
DoEvents statement inside that loop.
 
Thanks Dirk,
There is a loop code.

Dirk Goldgar said:
With the form's KeyPreview property set to Yes, this works for me:

Private Sub Form_KeyPress(KeyAscii As Integer)
KeyAscii = 0
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

But the form has to have the focus at the time; otherwise it doesn't see
the keystroke. Are you sure that your form has the focus?

Another possible reason for it not working is that you're doing
something in code, and there's a loop running that doesn't allow Access
to check for the keystroke. If that's the case, you need to put a
DoEvents statement inside that loop.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top