Hi HughLerwill,
Thanks for your help and suggestions. They were great!
This is the way I was able to get it done for Tab and Shift Tab to work. Since my form contains other command buttons like, Cancel, Exit, Save, I need to make sure these Tab stop properties are set to False, else, Tab control is hard to monitor whether it is for the Grid or for the form.
‘Declare a switch to monitor the Shift key
Dim svKey As Boolean
Private Sub Form_Load()
svKey = False
End sub
Private Sub fg2_KeyDown(KeyCode As Integer, Shift As Integer)
' code to allow Shift Tab or Tab to navigate left or 1 row up and column 3 or just the opposite
‘ User pressed Shift key, then keep track of it
If KeyCode = 16 Then
svKey = True
Exit Sub
End If
‘ Followed by a tab, then user wants to move the cursor left or to above row if applicable
If KeyCode = 9 And svKey Then
svKey = False
KeyCode = 0
With FG2
If .Col = 0 Then
If .Row > 1 Then
.Row = .Row - 1
.Col = 3
End If
Else
.Col = .Col - 1
End If
FG2.ColSel = .Col ‘ Highlight (not sure if needed)
End With
Exit Sub
End If
‘ User just pressed Tab, then move cursor right, etc.
If KeyCode = 9 And Not svKey Then
With FG2
If .Col < 3 Then
.Col = .Col + 1
Else
If .Row < .Rows Then
.Row = .Row + 1
.Col = 0
End If
End If
End With
End If
End Sub