Click event of a page or tab

I have a form with several pages/tabs.  When I click on the tab I would like the cursor to go to the first field for that tab.  If I put code in the click event for the 'doctor' tab and then step through my code it doesn't even fall through when the code.  If there is a better way to do this that is fine to.  
So far if I'm on the first field and go to another tab and then back...it's fine.  But if I go to the 2nd field and leave and come back it's still on the 2nd field same if on 3rd field etc.  It only goes back to where I left off.
Please help!

Private Sub Doctor_Click()
    DoCmd.GoToControl "Forms!frmIntake!fsubEmergDoctor.Form.txtEmergDocFirstName"
End Sub
BobRosasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TextReportCommented:
You should put the code in the On Change Event of the Tab Control.
Cheers, Andrew

Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0
        Case Me.Page1.PageIndex
        
        Case Me.Page1.PageIndex
 
    End Select
End Sub

Open in new window

0
TextReportCommented:
Oops type, sorry, added the setfocus also.
Cheers, Andrew
Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0
        Case Me.Page1.PageIndex
             Me.Text3.SetFocus
        Case Me.Page2.PageIndex
             Me.Text9.SetFocus
    End Select
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BobRosasAuthor Commented:
Worked like a charm!
Thank you so much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.