Private Sub TabCtl_Inv_Change
'I use the caption property because I can see what is on the captions
Select Case me.tabCtl_Inv.pages(me.TabCtl_Inv).Caption
Case "Tab 1 Caption"
Case "Tab 2 Caption"
'if the subform is not loaded, load it
if me.subTab2Subform.SourceObject = "" Then
me.subTab2Subform.SourceObject = "frm_MiscInvSub02"
endif
'assign the Name of the tab to txtTest if it is a new record
If me.frm_MiscInvSub02.form.NewRecord then
me.frm_MiscInvSub02.form.txtTest = me.[TabCtl_Inv].pages(me.[TabCtl_Inv]).Name
'but in reality, with this method, since you already know the tab that has the focus,
'you could use
me.frm_MiscInvSub02.form.txtTest = "Tab 2 Name"
End If
Case "Tab 3 Caption"
Case Else
msgbox "Invalid tab"
End Select
End Sub
Me.tabControlName.Pages(Me
If you have not assigned the tab a caption, then the "Name" property would be:
Me.tabControlName.Pages(Me
In case you don't know, you might try:
NZ(Me.tabControlName.Pages
This later method would return the caption (if it exists) or the name of the currently selected tab in your tab control. Make sure to replace "tabControlName" with the actual name of the tab control (not the individual pages).