Access 2003
I have a continuous form. The header contains several unbound fields used for allowing the user to enter parameters. The detail section contains four updatable fields -- (1) date in (2) time in (3) date out (4) time out. I would like to have the cursor positioned at the "date in" field of the "next" record" after the current record has been updated.
How can I do this in VBA code?
Thanks, in advance.
Cursor position on continuous form
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Cursor position on continuous form
Carol W.
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Cursor position on continuous form
If you have set the Cycle property of the form to "All Records" (this is the default setting) and made the "date in" control the first one in the tab order of the detail section, the focus should automatically be on the "date in" control of the next record when the user tabs out of the current one.
If you want the focus on the "date in" control whenever the user moves to a different record, you can use code in the On Current event of the form:
where txtDateIn is the name of the control bound to the "date in" field. If this name contains spaces or punctuation, enclose it in square brackets:
If you want the focus on the "date in" control whenever the user moves to a different record, you can use code in the On Current event of the form:
Code: Select all
Private Sub Form_Current()
Me.txtDateIn.SetFocus
End Sub
Code: Select all
Me.[Date In].SetFocus
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: Cursor position on continuous form
Thanks, Hans
We had the tab order incorrectly set in both the header and the detail. We were unable to straighten that out easily so we ended up putting the SetFocus statement that you suggested in the OnCurrent event. Works great!
We had the tab order incorrectly set in both the header and the detail. We were unable to straighten that out easily so we ended up putting the SetFocus statement that you suggested in the OnCurrent event. Works great!
Carol W.