Which tab has focus?

davesmith202

Employee of Access World
Local time
Today, 05:26
Joined
Jul 20, 2001
Messages
522
How can I tell which tab has the focus using code?

Thanks,

Dave
 
If I remember correctly, the default value of a tab control is the Page Index of whichever tab has the focus:

So, simply:

Code:
Me.tabControl
 
Check the tab value, e.g.
Dim PageNo as integer

PageNo = me!myTab.value

you may want to use it with the Tab Change event
 
That's strange. I have the following code behind the OnClick event of one of my tabs:

Private Sub To_Action_Click()
MsgBox "hi"
End Sub

But no message box appears. Is this a bug?

Dave
 
Put it on the Change() event.
 
Yes, that worked thanks! But why the OnClick event if it doesn't work?? Microsoft's idea of a joke??

When I click that tab, it will set a variable called strCurrentSubForm to a value. Then I use this value as follows:

strTo = Forms!frmADREnquiriesListMain(strCurrentSubForm).Email

But it does not work. What is wrong with this line of code?

It is supposed to be referring to a subform.

Thanks,

Dave
 
davesmith202 said:
Yes, that worked thanks! But why the OnClick event if it doesn't work?? Microsoft's idea of a joke??

Some events require special situations to trigger.

A combobox's NotInList event property can't be triggered if the LimitToList property is not set to Yes.
A form's GotFocus event won't fire if the form has an enabled control as the focus goes immediately to the control.

I'd say that this was a situation not unlike the form whereby the pages (because there's more than one) inherit their instance of the Tab Control's Click event.

Code:
strTo = Forms("frmADREnquiriesListMain")(strCurrentSubForm).Email
 
It says Access can't fid the field fsubADREnquiriesListALLEnquiries referred to in your expression.

Earlier on in the code, I have this:

strCurrentSubForm = "fsubADREnquiriesListAllEnquiries"

But the code line you gave gives the above error. Any idea why? The field called Email does exist on the subform. The subform is in list view if that makes any difference.

Thanks,

Dave
 

Users who are viewing this thread

Back
Top Bottom