Can keyboard keys be disabled??

G

Guest

I have a form that displays/updates records in a table. I need to control
the when the form moves to the next record. I have done this partially using
the cycle property. However I notice that if I press PGDN or PGUP on the
keyboard, the form changes.

Can I stop, block, or trap the keyboard keys or somehow disable these keys?
Thanks
 
D

Dirk Goldgar

Dick Hob said:
I have a form that displays/updates records in a table. I need to
control the when the form moves to the next record. I have done this
partially using the cycle property. However I notice that if I press
PGDN or PGUP on the keyboard, the form changes.

Can I stop, block, or trap the keyboard keys or somehow disable these
keys? Thanks

Most (if not all) keys are trappable by setting the form's KeyPreview
property to True and using the form's KeyDown event to examine the
key.and clear it if need be. But there are so many ways to move from
record to record, I wonder if this is the best approach for you to take
if you really need to control record navigation.

One alternative approach would be to use an unbound form and your own,
prvately maintained recordset, loading and unloading controls as needed.
Another might be to use some tricky code in the form's Current event to
keep moving the form back to the appropriate record until certain
criteria are met. Of course, if all you need to do is keep a record
from being updated, the form's BeforeUpdate event gives you control of
that. Without knowing exactly what need you're trying to meet, it's
hard to say what would be best.
 
G

Guest

Dirk,
Thanks for the Keypress/Keypreview suggestion. It almost works.

I have a fairly complex form already and I'm already using the On Current to
contol some of a second table movement. Maybe I'll play around with complete
manual control of the form- never done that before.

Here's what happens now, I set the keypreview, but it appears that PGDN,
PGUP, home, end, delete, and the keyboard keys are not trappable. I set a
debug point on the KeyPreview event, and it is never hit when I press any of
these keys. Regualar keys (a-z etc) trigger the debug just as expected.

I'm looking at an Acsii chart and do not find any character equivlant for
PGDN, PGUP etc. When I press the key, the form moves to the next record,
THEN it locks- and I can't get back!

Can you shed any light on this?
Thanks
Dick
 
D

Dirk Goldgar

Dick Hob said:
Dirk,
Thanks for the Keypress/Keypreview suggestion. It almost works.

I have a fairly complex form already and I'm already using the On
Current to contol some of a second table movement. Maybe I'll play
around with complete manual control of the form- never done that
before.

Here's what happens now, I set the keypreview, but it appears that
PGDN, PGUP, home, end, delete, and the keyboard keys are not
trappable. I set a debug point on the KeyPreview event, and it is
never hit when I press any of these keys. Regualar keys (a-z etc)
trigger the debug just as expected.

I'm looking at an Acsii chart and do not find any character equivlant
for PGDN, PGUP etc. When I press the key, the form moves to the next
record, THEN it locks- and I can't get back!

Can you shed any light on this?

I suggested using the KeyDown event, not the KeyPress event.
TheKeyPress event only fires for ASCII key values. If you use the
KyeDown event, you will see the keys you're talking about. The KeyCode
argument that is passed to the event procedure is the standardized scan
code for the key that was pressed. You can use vbKey... defined
constants to identify them:

vbKeyPageUp = 33
vbKeyPageDown = 34
vbKeyEnd = 35
vbKeyHome = 36
 
G

Guest

Thankyou, sometimes I just don't read things correctly.

Can you point me to a reference where I can find answers to these kind of
things myself. I don't seem to have much success with the MS Access Help or
oftentimes the MS Knowledgebase. I've been programming long enough to know
that what I want to do is possible, but knowing where to look has so far
eluded me.

Any suggestions would be greatly appreciated.
Thanks
Dick Hob
 
D

Dirk Goldgar

Dick Hob said:
Thankyou, sometimes I just don't read things correctly.

Can you point me to a reference where I can find answers to these
kind of things myself. I don't seem to have much success with the MS
Access Help or oftentimes the MS Knowledgebase. I've been
programming long enough to know that what I want to do is possible,
but knowing where to look has so far eluded me.

Any suggestions would be greatly appreciated.

Unfortunately, the truly excellent online help that came with Access 97
was completely bollixed up with Access 2000, and hasn't recovered yet.
I learned most of what I know about Access by reading the online help as
if it were a book, by reading the Access newsgroups, by trial and error,
and from one or two good books. If you have a programming background,
you can probably make good use of the best Access book for developers
that I've ever come across: _Access <version> Developer's Handbook_, by
Getz et. al., from Sybex. There are versions for Access 97, 2000, and
2002, but not 2003. Versions from 2002 on come in two volumes. From a
more general point of view, I can recommend John Viescas' _Access 2003
Inside Out_, from Microsoft Press.

For a web resource with a wealth of how-to tips and handy code snippets,
I suggest you look at The Access Web: http://www.mvps.org/access . And
there are lots of links there to other good sites.
 
G

Guest

Dirk,
I have both of the GETZ books you mentioned as well as Sybex VBA Developers
Hadnbook by Gets and Access2k VBA Handbook by Sue Novalis(?). All are good
books, but none of them really get into the nit picky details that I
frequently find I need an answer for. I find it almost impossible to phrase
the right keywords or pick the correct index topic to find what I need. I
guess I just keep asking questions on forums like this and hope guys like you
can come to my rescue.

Thanks for you help, I'm sure I'll be back!
 

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

Top