Go to Specific Field

R

Roger Bell

I have a Command Button on a Form to allow a new record to be inserted.
What I would like is that when this button is clicked the cursor moves to
the nominated field in the new record.
Can I add some code to that already shown to achieve this?
On Click Event Procedure:

Private Sub Insert_Record_Click()
On Error GoTo Err_Insert_Record_Click


DoCmd.GoToRecord , , acNewRec

Exit_Insert_Record_Click:
Exit Sub

Err_Insert_Record_Click:
MsgBox Err.Description
Resume Exit_Insert_Record_Click

End Sub

Thanks for any help
 
K

Keith Wilby

Roger Bell said:
I have a Command Button on a Form to allow a new record to be inserted.
What I would like is that when this button is clicked the cursor moves to
the nominated field in the new record.
Can I add some code to that already shown to achieve this?
On Click Event Procedure:

Private Sub Insert_Record_Click()
On Error GoTo Err_Insert_Record_Click


DoCmd.GoToRecord , , acNewRec

Exit_Insert_Record_Click:
Exit Sub

Err_Insert_Record_Click:
MsgBox Err.Description
Resume Exit_Insert_Record_Click

End Sub

Thanks for any help

Hi Roger,

Use the SetFocus method:

Me.ctlMyControl.SetFocus

where ctlMyControl is the name of the control you want the cursor to go to.

HTH - Keith.
www.keithwilby.com
 

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