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?
 
TextReportConnect With a Mentor Commented:
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
 
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
 
BobRosasAuthor Commented:
Worked like a charm!
Thank you so much!
0
All Courses

From novice to tech pro — start learning today.