VBA Syntax for Tab Control on a form (1 Viewer)

BJF

Registered User.
Local time
Today, 04:45
Joined
Feb 19, 2010
Messages
133
Hello all,

I am trying to set focus to a specific field on my form every time that this particular tab is selected.

I have tried putting the following code into the 'on click' event of that tab.


Me.TabSalesOrders.Pages("SALES ORDER")!SearchSoNumber.SetFocus


TabSalesOrders is the name of my tab control
SALES ORDER is the name of that page or tab
SearchSoNumber is the field I'm trying to set focus to whenever switching to this tab.

I dont get an error from this, it just doesn't do anything. The focus goes to an undesired field. What am i doing wrong?

Put it this way, when i open the form i have code on current to set focus to SearchSoNumber and it works great, but if i switch to another tab and then back, the focus is in a field that i dont want having focus.

Thanks,
BJF
 
Last edited:

moke123

AWF VIP
Local time
Today, 04:45
Joined
Jan 11, 2013
Messages
3,908
try the onchange event of the tab control and use the tab control value.

Code:
if Me.TabSalesOrders.value  = 0 then
SearchSoNumber.SetFocus
elseif  Me.TabSalesOrders.value  = 1 then
....
elseif  Me.TabSalesOrders.value  = 2 then
.....
end if
 

BJF

Registered User.
Local time
Today, 04:45
Joined
Feb 19, 2010
Messages
133
Thanks moke123,

it worked perfectly!

was driving me crazy, thx for ending my misery!
 

moke123

AWF VIP
Local time
Today, 04:45
Joined
Jan 11, 2013
Messages
3,908
your welcome, good luck with your project.
 

Users who are viewing this thread

Top Bottom