Command button to tab within tabs (1 Viewer)

Jennifer K

New member
Local time
Yesterday, 23:24
Joined
Nov 25, 2020
Messages
2
Hi everyone.

I have an Access Form I am building in Access 2016 that has 13 separate tabs. I wanted to build a command button at the bottom of the form to move within the tabs by using the button instead of having to return to the top and click through. This way, you can tab through the fields and just hit enter instead of having to pick up the mouse and return to the top. I cannot figure out how to do this. Is this even possible? I was thinking maybe I could build a macro, but I don't want to struggle through it if the attempt would be fruitless. Thanks!
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:24
Joined
Oct 29, 2018
Messages
21,471
Hi. Welcome to AWF!

To move through the pages of a Tab Control, you can simply assign the page number to the tab control itself. For example, this code has the same effect as clicking on the second tab.

Me.TabControlName=1

Hope that helps...

PS. Please note page index is zero-based.
 

Jennifer K

New member
Local time
Yesterday, 23:24
Joined
Nov 25, 2020
Messages
2
Hi. Welcome to AWF!

To move through the pages of a Tab Control, you can simply assign the page number to the tab control itself. For example, this code has the same effect as clicking on the second tab.

Me.TabControlName=1

Hope that helps...

PS. Please note page index is zero-based.
Please forgive my utter ignorance! I have names for the 13 tabs already that pertain to each category of the form. Can I incorporate those names into the code? Is there a certain type of macro this has to be? I tried doing it the way you described, and I'm getting error messages... And thank you!
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:24
Joined
Oct 29, 2018
Messages
21,471
Please forgive my utter ignorance! I have names for the 13 tabs already that pertain to each category of the form. Can I incorporate those names into the code? Is there a certain type of macro this has to be? I tried doing it the way you described, and I'm getting error messages... And thank you!
Hi. Each tab has a name, but the entire thing as a whole also has a name. That's the one I was referring to.

Also, there may be a way to do what you want without having the user click a button to go to the next tab. For example, in the LostFocus event of the last control on each tab, you could send the focus to the first control on the next tab.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:24
Joined
Jul 9, 2003
Messages
16,280
Sounds like you need to setup the "Tab Order" so you just press the Tab key and it will move from One control to the next.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:24
Joined
Jul 9, 2003
Messages
16,280
Sounds like you need to setup the "Tab Order" so you just press the Tab key and it will move from One control to the next.
However if you mean you want to move from one tab page to the next, backwards and forwards without having to go to the top of the Tab control and pressing on any particular tab with your mouse, then have a look at the attached sample:-
 

Attachments

  • Command button to tab within tabs_1a.zip
    331.9 KB · Views: 117

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:24
Joined
May 7, 2009
Messages
19,239
you can use VBA to perform the Action of the Button:
Code:
private sub button_click()
static intX as integer
if intX = 0 then
    intX = 1
else
    intX = intX + 1
end if
if intX > 12 then intX = 0
me![tabControlName] =  intX
me!button.Caption = "@ " & me![tabControlName].Pages(me![tabControlName]).Caption
end sub
 

Users who are viewing this thread

Top Bottom