Up/Down Arrow keys on Form - help please

S

Steve Marshall

Hello all,

I have a form with a large number of unbound text fields on which I want the
down-arrow key to behave exactly the same as Tab, and the up-arrow key the
same as Shift-Tab. This already happens if nothing is entered into a field,
but if something is entered, Access seems to require the Tab key (or
shift-Tab) to move the focus.

I have set the form's KeyPreview property to Yes, and put the following code
in the KeyDown event:

Private Sub Form_KeyDown (KeyCode as Integer, Shift as Integer)

If KeyCode = vbKeyDown Then
KeyCode = 9
Shift = 0
End If

If KeyCode = vbKeyUp Then
KeyCode = 9
Shift = acShiftMask
End If

End Sub

But it doesn't work. Down-arrow is OK, but up-arrow is being treated the
same, i.e. my modification to the Shift parameter is not being correctly
interpreted. Is this the right way to do this? Can it be done at all?
 

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