Tabs Onclick Event

G

Guest

Hi all
I have an unbound main form with couple of tabs with subforms embeded on
them. What I want to do is I have some control (ie txtboxes, cbo boxes, and
lstboxes) that I would like to be displayed depending on the selected tab.
I put some VBA code to control the visibility of these controls on the
OnClick event of each tab but I don't see anything being hidden or rather no
action fires.

How can i control hiding/unhiding of these controls depending on the current
tab I am on?

Any answer would be more than helpful.

THanks
 
R

ruralguy via AccessMonster.com

As you have discovered, the Click event is practically useless. Use the
Change event of the Tab Control.

Using YOUR TabCtl name of course!

Private Sub TabCtl2_Change()
On Error GoTo Err_TabCtl2_Change

Select Case Me.TabCtl2.value

Case 0
'-- You've moved to the 1st tab
'...Some code
Case 1
'-- You've moved to the 2nd tab
'...Some code
Case Else
'-- This will not occur with only two tabs
'...Some code
End Select

Exit_TabCtl2_Change:
Exit Sub

Err_TabCtl2_Change:
MsgBox "Error No: " & Err.Number & vbCr & _
"Description: " & Err.Description
Resume Exit_TabCtl2_Change

End Sub
 
R

ruralguy via AccessMonster.com

You're very welcome.
That was exactly what I was looking for.
Thanks Rural Guy.
As you have discovered, the Click event is practically useless. Use the
Change event of the Tab Control.
[quoted text clipped - 41 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top