Add New Record Command Button

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
In the click event of the new record command button, add one line of code
after new record is added:
Me.MyFirstControl.SetFocus
 
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.
 
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
 
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
 
Yes, I know the name of the control, I just didnt ask the question right.

Thank you for the information, it is most appreciated.
 
Back
Top