Full Version: Move Focus
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
Knuckles
I am using a tab control on a form with a different form within each tab. When I select the tab the focus is set to the first record (which highlights the record).
I would like to shift the focus so that when the tab is selected the focus moves to a command button but I can not figure out where to attach the code????

I thought it would have been on the "on click" event of the tab but that did not work.

Any help would be appreciated.

Knuckles
missinglinq
Accidental duplicate deleted.
missinglinq
The first thing to understand is that tabbed pages are indexed starting with zero, i.e. the first page has a value of 0, second page has a value of 1, third page has a value of 2, etc.

Secondly, you need to understand that the OnClick event of a tabbed page only fires when you click on the page itself, not the tab at the top of the page!

Lastly, you need to understand that the tabbed control change event fires anytime the tabbed pages change. But to base something on the change event, you have to identify the particular page that has focus.

CODE
Private Sub YourTabbedControl_Change()
  Select Case YourTabbedControl
    Case 0  ‘First Page
      ‘Code for Page 1
    Case 1  ‘Second page
      ‘Code for Page 2
   Case 2   ‘Third page
     ‘Code for Page 3
  End Select
End Sub


.

Knuckles
That did it. Thanks so much. thumbup.gif
missinglinq
Glad we could help!

Good luck with your project!

Linq ;0)>
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.