stay in the same field after tab

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Everyone
I have a main form and subform. Subform is continious and mainly for data
entry. Is there a way to move cursor verticaly in the subform (like with
"down" key) with tab. People find it much easier with data-entry. So we'd
start with first record in subform - move down on tab until the last record
then move to next field.
Is it possible?
 
Hi,
just set the Tab Stop property of the other controls in this subform to NO.
This only leave ONE control (the first one) to have the tab stop property set
to yes. If you now press tab it will jump to that control in each record.
HTH
Good luck
 
Hi Oliver
Thanks for a tip, but it's not what I need. I need to enter data in all most
of the fields, and after entering verticaly in one field I'd like to be able
to do the same in the next field. Method you sugested works only in one field.

Thanks
Barb
 
The Enter key can be set to jump to the same field in the next record.
Check the options under
Tools->Options->Keyboard->Move After Enter
Change it to Next Record.


Potentially, you could change this setting in code:
'aircode

Dim intOldOption as integer

'in Subform gotfocus
intOldOption = GetOption("Move After Enter")
SetOption "Move After Enter", 2


'in Subform LostFocus
setOption "Move After Enter", intOldOption

------
but be warned, some users really don't like their settings to be changed

HTH,

Kevin
 
If you are willing to allow the user to use the up arrow and down arrow keys
to move between records and remain in the same control then here is a routine
that will work:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim lngRecords As Long
Dim lngPosition As Long

lngRecords = Me.Recordset.RecordCount - 1
lngPosition = Me.Recordset.AbsolutePosition
If KeyCode = vbKeyUp Then
If lngPosition <> 0 Then
Me.Recordset.MovePrevious
Else
KeyCode = 0
End If
ElseIf KeyCode = vbKeyDown Then
If lngPosition = lngRecords Then
KeyCode = 0
Else
Me.Recordset.MoveNext
End If
End If

End Sub

It requires that the form's KeyPreview property be set to Yes so the form
will see the keystroke before the control. The reason for the KeyCode = 0 is
that if you are on the first record and press the up arrow, it will move to
the previous control on the same record. Setting the KeyCode to 0 makes the
control think no key had been pressed, so it just stays on the first record
in the same control. The same is true of the last record with the down arrow
key.
 
Thank you very much for all your help. I'll try it first thing tomorrow
morning, but it looks promissing. Hopefully I will not mess up the code.
Barb
 
Back
Top