SetFocus

CanWest

Registered User.
Local time
Today, 12:40
Joined
Sep 15, 2006
Messages
272
I am trying to set the focus to a text boxt (txtSearch) when the second tab (Clients) in a tab control is clicked. The tab control is on a form called frm_MainMenu

I have tried several suggestions I found in these forums on the onClick event of the Clients tab

These include
Code:
    Forms!frm_MainMenu!txtSearch.SetFocus

    frm_MainMenu!txtSearch.SetFocus

    me.txtSearch.SetFocus

None of these seem to work

Does anyone have any ideas

Thanks
 
Forms!frm_MainMenu!txtSearch.SetFocus

frm_MainMenu!txtSearch.SetFocus

me.txtSearch.SetFocus

Controls on each Tab-Page of a Tab Control have different Tab Index Sequence Numbers.

Display the txtSearch Textbox's Property Sheet (ALT+Enter or F4 when the control is in selected state). Find the Tab Index property and change the value to 0. The setFocus thing will not work.
 
Here's a short tutorial I give people that addresses your problem:

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 TabbedControl 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

Since the Pages are Zero-Based, code for the second Page would be placed in Case 1 in the above code.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom