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!

a TOUGH question about textboxes

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
I have a continous form with several text boxes in each band. If a user presses the up arrow, the cursor moves one notch to the LEFT. That is the default behavior.

My user wants the up arrow to push the cursor to the corresponding textbox in the previous row. He wants the up arrow to literally move him up.

Perhaps I could identify the key he is pressing in an event handler, then change the default behavior if he was pressing the up arrow. Does anyone have an idea on how to implement that?
 
OhioSteve,
Rough concept. Turn the key preview for the form on then use code something like this in the [tt]KeyDown[/tt] event for the form.

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
  Case vbKeyDown
    KeyCode = 0
    If Not Me.Recordset.EOF Then
      Me.Recordset.MoveNext
    End If
  Case vbKeyUp
    KeyCode = 0
    If Not Me.Recordset.BOF Then
      Me.Recordset.MovePrevious
    End If
End Select
End Sub

Setting [tt]KeyCode = 0[/tt] basically tells the form that no key was pressed so it ignores the user input. You may want to take a look at the help topic for the [tt]KeyDown[/tt] event to see if you want to do anything with the [tt]Shift[/tt] argument.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top