ActiveX controls on Tab control page
If you insert an ActiveX control on Tab control page, like any other Access control, - then you could have a problem, like ActiveX control jumps from place you insert it, or control itself is not displayed properly. The workaround – is to insert control directly on a form, move and size it at desired place, “Bring it to front” above the tab control and then set it visible property to False. Now you can use Tab control Change event to make ActiveX control visible, when certain page is selected:
Private Sub TabCtl0_Change()
Select Case Me.TabCtl0.Pages(Me.TabCtl0).Name
Case "MyPageWithActiveXcontrol"
Me.MyControl.Visible = True
Case Else
Me.MyControl.Visible = False
End Select
End Sub
1 Comments:
Taking your idea a step further, I found a
simpler way to avoid the problem. Simply make all controls on all pages of
the tab control invisible, then run code from the tab control's On Change
event to make only the controls on the current page visible (also need to
run it from the form On Open or On Current event so that the controls are
initially displayed).
Below is the code I came up with (for a tab control named "tabMain"). Seems
to resolve the problem, and allows you to keep all your controls on the tab
control, instead of moving them off.
Dim ctl As Control
Dim pg As Page
Dim blnVisible As Boolean
For Each pg In Me.tabMain.Pages
blnVisible = (pg.PageIndex = Me.tabMain)
For Each ctl In pg.Controls
ctl.Visible = blnVisible
Next
Next
Post a Comment
<< Home