SetFocus question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with 4 tabs. Each of the 4 pages has individual text boxes.
On each of those pages I have a text box selected to receive the focus when
the tab for that page is opened. My problem is this. If the tab is
double-clicked, the focus will not go to the text box the VBA code assigns it
to. I have tried writing this code to the on click property of the tab, but
it does not work. Actually, it does not work on any of the tab properties.

I am using Access 2003. Any help would be appreciated.
 
The tab_Click event fires when you Click somewhere on an active tab page
(just like a Form_Click event), not when you Click to activate the tab. You
want the tab_Change event:

Private Sub tabMain_Change()
Select Case Me.tabMain.Pages(Me.tabMain.Value).Name
Case "pgScenarioDataMaint" 'PageIndex 0
txtYada0.SetFocus
Case "pgGlobalDataMaint" 'PageIndex 1
txtYada1.SetFocus
Case "pgReports" 'PageIndex 2
txtYada2.SetFocus
Case "pgImportData" 'PageIndex 6
txtYada6.SetFocus
End Select
End Sub

An alternate method is to test for the PageIndex value:
Select Case Me.tabMain.Pages(Me.tabMain.Value)
Case 0 'Scenario Data
Case 1 'Global Data
etc....

--
HTH,

George Nicholson
(Please post responses to newsgroup but remove "Junk" from return address if
used)
 
Back
Top