Strange tab results

I have a form with several tabs.  What is the best way to make the cursor jump to the first field on the next tab when leaving the last field on the current tab?  I've tried this in the onexit event of the last field on the current tab but the tab controls gets real erratic with no predictable result.  In fact, if I cursor to the FIRST field on the current tab, I get taken to the first field on the next tab as an example.


Me.pagTabName.SetFocus
SteveL13Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
There is no convenient way to do what you are asking for.

"In fact, if I cursor to the FIRST field on the current tab, I get taken to the first field on the next tab as an example."

Do you mean if you tab out of the last field on a tab it takes you back to the first field on that tab?  What I have found is that if you have the "Cycle" property (Other tab of the Properties dialog set to "All Records", tabbing out of the last control on the first tab will actually change to the next record and move the cursor to the control with the lowest tab index property on the current tab.

The only way I can think of to do this would be to add some code to the KeyDown event of the last control on the tab that looks something like:

Private Sub ControlName_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = vbKeyTab Then
        KeyCode = 0
        Me.Page12.SetFocus   '<= page12 is tab #2 in my test
        Me.Months.SetFocus  '<= Months is the controlname of the first field on the 2nd tab
    End If
    
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
No. I want to go to the first field of the next tab.
0
Dale FyeOwner, Developing Solutions LLCCommented:
Steve, you are talking about the tab control, on a form, right?

There is no easy way to do this.  Tab controls are meant to allow the user to work within a single tab, and manually select the next tab they want to go to.

However, the code I provided will do what you want, you just need to modify it to use the correct tab page names and control names.  You must put the code in the KeyDown event of the last control on each tab, and then change the two lines that identify the tab which you want to have the focus, and the control within that tab that you want to move to.

I strongly encourage you to make sure that your forms "Cycle" property is set to Current Record as well, to prevent you from inadvertently moving to the next record.


Dale
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

SteveL13Author Commented:
I'll try it now.  By the way, I always cycle forms to Current Record.  I don't know why anyone would ever do anything different.
0
SteveL13Author Commented:
Thanks again as always.
0
Dale FyeOwner, Developing Solutions LLCCommented:
You're welcome.

Glad that worked for you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.