Set Focus after New Record

eramirez

Registered User.
Local time
Today, 12:34
Joined
Dec 10, 2007
Messages
17
Hi

This is probably an easy fix, but I have a basic command button on a form to add new record, but after a new record is added, I want the cursor to be a certain field. Thanks for your help.

this is the code behind the button:


Private Sub addnew_Click()
On Error GoTo Err_addnew_Click

DoCmd.GoToRecord , , acNewRec

Exit_addnew_Click:
Exit Sub
Err_addnew_Click:
MsgBox Err.Description
Resume Exit_addnew_Click

End Sub


Enrique
 
How about

Me.ControlName.SetFocus
 
Thanks Paul!

That seemed to work.

so just to be sure, this is how it shoud look?

Private Sub addnew_Click()
On Error GoTo Err_addnew_Click

DoCmd.GoToRecord , , acNewRec
ME.ControlName.SetFocus

Exit_addnew_Click:
Exit Sub
Err_addnew_Click:
MsgBox Err.Description
Resume Exit_addnew_Click

End Sub
 
No problem Enrique. Yes, that looks correct to me.
 

Users who are viewing this thread

Back
Top Bottom