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

Trap Keypress or Keydown on database start

Status
Not open for further replies.

davidwv

Programmer
Sep 14, 2001
4
US
I'd like to be able to determine, in a module, if the user is pressing a certain key (doesn't matter which, can be normal key or shift/ctrl/alt or combo). I need to make this determination before anything else happens. I figured I'd have an Autoexec macro run my module, but from there I can't figure out where to go next.

It seems that all keyboard event routines/methods are tied to an object (form or control). Am I going to have to pull something in from a Windows DLL?

Thanks in advance!
-dave

 
Have a look at the AutoKeys macro in help.

I wouldn't usually recommend using macros for *anything*, but this is the only way I have found to trap key strokes without tying it to a form.

HTH,

Ed Metcalfe.

Please do not feed the trolls.....
 
Thanks for the tip. I agree with the "anti-macro" sentiment, btw.

Before I got your tip, I "engineered" another solution. It wasn't clear in my question, although it was hinted at in the "subject", but I wanted to detect if the user was holding down a key during database startup (in my case, the Ctrl key seems to work best).

I created a new "start up" form (just an empty form with a bitmap for a backgroud -- sort of like a splash screen) called from the AutoExec macro. The form has these properties:

KeyPreview=True

OnKeydown:
If Key = 17 (ctrl key) then
<do whatever is required if user is holding ctrl key>
<open &quot;real&quot; startup form and close this one>
End If

TimeInterval:1000

OnTimer:
<do whatever is required if user is NOT holding ctrl key>
<open &quot;real&quot; startup form and close this one>

Seems to work OK. Some key combos are not good (like Shift, because that's Access' signal to bypass the autoexec macro).

Thanks again for your tip. I had totally forgotten (on purpose?) about AutoKeys.

-dave
<insert catchy slogan here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top