Home Privacy Policy Feedback Link to us Site Map

Access: Set the focus on the first field in a form whenever a record is viewed in Access 2003/XP/2000/97


Question:  In Access 2003/XP/2000/97, I have a control button to "Add a New Record" on a form. I realized that when I clicked on it, even though a new record comes up, the cursor does not go directly to the first field of data entry. How can I get the cursor to move to the first field on the form?

Answer:  To make sure that the focus is on the first field whenever a new record is added...or for that matter, whenever you view a record in the form, try the following VBA code on the form's "On Current" event:

First_Field.SetFocus


For example, if your first field was called CompanyName, you would use the following VBA code:

Private Sub Form_Current()

    CompanyName.SetFocus

End Sub