Functional buttons

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello everybody,
I would like to use, in a user form, functional buttons (i.e.: F1; F2; etc)
for some events : it's any way to realize this?

Many thanks for your suggestions.
 
Giangi said:
I would like to use, in a user form, functional buttons (i.e.: F1; F2; etc)
for some events : it's any way to realize this?


There are a couple ways to do that. The easiest is to use a
AutoKeys macro. Generally, it's a good idea to set the
macri's action to RunCode so it immediately jumps to a VBA
procedure. This approach has global scope so you would need
to use code in the procedure to restrict the actions to a
single form.

A different approach that applies to a specific for is to
set the form's KeyPreview to Yes. This allows you to
intercept keystrokes using the form's KeyDown event. This
approach is general to all keystrokes so you'll have to use
code to select which keys you want to process and which ones
should be passed on to the active control.

Check all this in VBA Help and then set up a dummy test form
to explore these capabilities in detail.
 
The choice between the 2 methods mentioned by Marshall should be made as
follows:
If you want some F-key to perform the same action on every form, use
Autokeys. But if an F-key does different things on different forms, then it
is infinitely easier to set the form's KeyPreview property and KeyPress event
for the desired F-key. Look up these topics in Access help:
KeyPreview
KeyPress
KeyDown, KeyUp
 
Many thanks Ted and Marsh.
I think to choice "same action on every form" (i.e: F3 for update or F4 for
add etc.)
Good job.
 
Giangi: Be careful! Same action on every form means when Form1 is open, F3
updates Table1, when Form2 is open, F3 updates Table1 also. Is that what you
really want? I suspect you want to update different tables on different forms
- that requires coding for the FORM's keypress event, not using AutoKeys. You
could code logic behind Autokeys to determine which form is active to do the
right thing, but it's a lot easier with code that is local to each form.
 
Thanks for remember me this important particular upon Autokeys.
I will use specific coding form by form.
Good bye, Ted.
 

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

Back
Top