Add New Record Command Button

G

Guest

I have added a add new record command button to my form. I would like to
modify it so when a user clicks on the button, it will take them to the first
blank control in my form of the new record. How do I do this? Thanks.
 
G

Guest

In the click event of the new record command button, add one line of code
after new record is added:
Me.MyFirstControl.SetFocus
 
D

Dirk Goldgar

Shirley said:
I have added a add new record command button to my form. I would
like to modify it so when a user clicks on the button, it will take
them to the first blank control in my form of the new record. How do
I do this? Thanks.

Don't you actually know the name of the control you want to go to on the
new record? Assuming you do, you can add a line like this to the event
procedure for the command button:

Me!YourControlName.SetFocus

Replace "YourControlName" in the above line with the name of the control
you want to go to.
 
G

Guest

currently the code in the On Click event is as follows: (where would I put
the new line of code?) Also the name of the control I want to go to
GroupingType (if that makes a difference)

Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click
DoCmd.GoToRecord , , acNewRec
Exit_Add_Record_Click:
Exit Sub
Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click
End Sub
 
G

Guest

I added the line to your code. See below

Shirley said:
currently the code in the On Click event is as follows: (where would I put
the new line of code?) Also the name of the control I want to go to
GroupingType (if that makes a difference)

Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click
DoCmd.GoToRecord , , acNewRec Me.MyFirstControlNameHere.SetFocus
Exit_Add_Record_Click:
Exit Sub
Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click
End Sub
 
G

Guest

Yes, I know the name of the control, I just didnt ask the question right.

Thank you for the information, it is most appreciated.
 

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