Cathcing arrow strok, and navigate between text boxes.

M

Mr. Smith

Hi.
I have a form with 144 text boxes. 12 rows/12 columns. When the usere use
the down arrow key, the next text box in the taborder get focus. Nice
enought. this takes care of the "up/down" navigation.

However I want to cath left/right arrows also, to allow sideways navigation.

Suggested logic.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 39 Then 'Right arrow
Controls(Screen.ActiveControl.TabIndex + 12).SetFocus
Case 37
Controls(Screen.ActiveControl.TabIndex - 12).SetFocus
End Select
End Sub

Silly thing is that this only works on a form when no control got focus
(like never.....)

I tried to make a function
Public function KeyDown(KeyCode as integer)
'Do navigation
End function

But how do i pass the KeyCode as a parameter from "OnKeyDown" event on a
text box?
I set the "OnKeyDown" event on all 144 text boxes to =KeyDown(), but I needs
the keycode as parameter.

As you might understand I'm trying to build a standard cell matrix with
"Excel" feeling through textbox mosaic, and that is the hole point, as it
alows "super" flexible development on a later stage in the application....

Kind regards
Mr. Smith
 
D

Douglas J. Steele

I don't think you have any choice but to put code in the AfterUpdate events
of each of the 144 text boxes.

Note, though, that it's possible to write VBA code to do this for you: look
at the CreateEventProc and InsertLines methods in the Help file.
 
M

Mr. Smith

Ok, thanks Douglas.


Douglas J. Steele said:
I don't think you have any choice but to put code in the AfterUpdate events
of each of the 144 text boxes.

Note, though, that it's possible to write VBA code to do this for you:
look at the CreateEventProc and InsertLines methods in the Help file.
 
M

Mr. B

Mr. Smith,

As usual, Doug has given you some great advise.

I would just like to invite you to go to this link and download the
"ExcelTypeMovement.zip" file.
http://www.askdoctoraccess.com/DownloadPage.htm

This file has and example of what you are wanting to do in two different ways.

One is where the up and down movement is the normal movment as you have
described, and then code exists that provides the movement for the right an
left arrows.

The other is that the right and left movements are the normal movements and
the code provides the up and down movments.

There is documentation about how the forms were created.

HTH
Mr. B
askdoctoraccess dot com
 

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