Access form control focus

M

MrClean

I have created a form of text boxes and set the cycle to current record.
After populating all of the controls with data and the cursor returns
to the first control in the tab order everything is fine.
If I continue to tab through the controls on the form without changing
or adding data everything is still fine.
But, if a control (call it control x) other than the first control in
the tab order has the focus before I press the new record button, or next
record button at the bottom of the form in order to display a blank form.
Control x has the focus in the blank form rather than the first control in
the tab order.
If I were to select data entry from the records menu list, or new
record from the insert menu list, the first control in the tab order has the
focus on the new record.
How do I force the first control in the tab order to gain initial focus
in a situation where this does not occur?
 
A

Allen Browne

Perhaps you could use the form's Current event to set focus to the desired
control if it is a new record.

1. Open the form in design view.

2. Open the Properties sheet.

3. Set the form's On Current property to:
[Event Procedure]

4. Click the Build button (...) beside this property.
Access opens the code window.

5. Set up the code like this:

Private Sub Form_Current()
If Me.NewRecord Then
Me.[YourControNameHere].SetFocus
End If
End Sub
 

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