Solved SetFocus (1 Viewer)

RevJeff

Registered User.
Local time
Today, 18:56
Joined
Sep 18, 2002
Messages
125
Hi, I have a form with a Tab Control on it. I have 3 tabs on the Tab Control and I am trying to SetFocus to a specific Button on each Tab when I click those tabs, but it doesn't work. It's acting like every time I click those tabs it chooses a different focus on that tab.

I hope I explained that clearly. Any thoughts?

Thanks!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:56
Joined
Oct 29, 2018
Messages
21,474
Hi. Can you please show us the code you're trying to use?
 

Minty

AWF VIP
Local time
Today, 23:56
Joined
Jul 26, 2013
Messages
10,371
What code are you using and in what event?
You probably need to use the TabChange event, and also work out which tab you are on.

Also, check the tab order on the tab control, that might fix things for you.
 

RevJeff

Registered User.
Local time
Today, 18:56
Joined
Sep 18, 2002
Messages
125
I don't really have much code. I tried this on the On Click for the specific tab, which only works if you click on the body of the Tab, not the actual Tab at the top. I then set the Tab Order of the button on the Tab and that still didn't work.

Code:
Private Sub REPO_Click()

    Me.btnSelectFileREPO.SetFocus

End Sub
 

Attachments

  • Capture.PNG
    Capture.PNG
    5.3 KB · Views: 363

Minty

AWF VIP
Local time
Today, 23:56
Joined
Jul 26, 2013
Messages
10,371
Like I said - with a Tab control you need the On Change event of the tab control, and you will need to know which tab page you have selected.
Tab controls aren't the most intuitive to work with Use something like

Debug.print Me.MyTabControl

To tell you which page you are on.
 

RevJeff

Registered User.
Local time
Today, 18:56
Joined
Sep 18, 2002
Messages
125
Like I said - with a Tab control you need the On Change event of the tab control, and you will need to know which tab page you have selected.
Tab controls aren't the most intuitive to work with Use something like

Debug.print Me.MyTabControl

To tell you which page you are on.
That worked perfectly! Thank you!
 

Isaac

Lifelong Learner
Local time
Today, 15:56
Joined
Mar 14, 2017
Messages
8,777
Or, actually change the page. Me.TabControlName.Value=2 (then, set focus to a button on that tab)
 

Users who are viewing this thread

Top Bottom