new record button in a form

marian68
marian68 used Ask the Experts™
on
I have a form with 3 pages.
I would like to know if it is possible, after I finished entering a new record(so I am on the page 3) when I push on the  button "new record"  to go automatically to the beginning of the 1st page to start entering another record?
Thank you very much,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
in the click event of the button, place this codes

docmd.gotorecord,,acnewrec
docmd.gotopage 1
Top Expert 2016

Commented:
if you are using tabcontrol, use this

me.tabcontrol.pages(0).setfocus
docmd.gotorecord,,acnewrec

Author

Commented:
I was talking about the default button of Access to create a new record.
Do you recommend me to create a button and to use the above code?
Thank you very much
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Top Expert 2016

Commented:
do you mean the button with >* ?

i think you better create your button for this purpose

Author

Commented:
Yes the button you mentioned >*,
Ok, I will create my own button for this purpose and I will tell if it works in a couple of minutes.
Thank you very much

Author

Commented:
I built a command button on the last page of the form.
When I am using the first code the form is ready for a new record but I remain on the same page.
When I am using the 2nd code it shows me the it is something wrong with "tabcontrol" from your code, it is blackened. Do I have modify the "tabcontrol" with something?
Here are the code
Private Sub Command667_Click()
Me.TabControl.Pages(1).SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub
Thank you
Top Expert 2016
Commented:
You have to change TabControl with the name of your tab control.

Author

Commented:
It worked by instead of this chunk of code
"tabcontrol.pages(0)"
I put the name of the first page of the form
Thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial