467,920 Members | 1,218 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,920 developers. It's quick & easy.

enable controls on tab control form

Hello,

I am trying to enable controls based on the value of a checkbox, i.e.
if value = true then enable.

I have a tab control form with controls on 4 tabs. I have some code
(below) on the tab control "on change" event.

This works for the 'first tab' but then does not work for any other
tab.

Any ideas?

Thanks!

Dave

Private Sub TabCtlPage2_Change()

CmdExit.SetFocus
'set the focus to exit button
Select Case TabCtlPage2.Value

Case Is = 1

For Each c In Me.Controls

If c.Tag = "PREABY" Then
c.Enabled = Nz(Me.checkbox_PREABY.Value, True)
End If

If c.Tag = "PREOBC" Then
c.Enabled = Nz(Me.checkbox_PREOBC.Value, True)
End If

If c.Tag = "PREMT" Then
c.Enabled = Nz(Me.checkbox_PREMT.Value, True)
End If

If c.Tag = "PREPMCT" Then
c.Enabled = Nz(Me.checkbox_PREPMCT.Value, True)
End If

Next

Case Is = 2
For Each c In Me.Controls

If c.Tag = "CAROVC" Then
c.Enabled = Nz(Me.checkbox_CAROVC.Value, True)
End If

If c.Tag = "CARVCT" Then
c.Enabled = Nz(Me.checkbox_CARVCT.Value, True)
End If

If c.Tag = "CARPCBH" Then
c.Enabled = Nz(Me.checkbox_CARPCBH.Value, True)
End If

If c.Tag = "CARPCTH" Then
c.Enabled = Nz(Me.checkbox_CARPCTH.Value, True)
End If

Next

Case Is = 3

For Each c In Me.Controls
If c.Tag = "TREART" Then
c.Enabled = Nz(Me.checkbox_TREART.Value, True)
End If
Next
End Select
End Sub

Jan 12 '06 #1
  • viewed: 2881
Share:
2 Replies
da*********@acgov.org wrote:
This works for the 'first tab' but then does not work for any other
tab.


This is because your code is using a select statement to check what the
value of TabCtlPage2.Value is. In other words, what is the currently
displayed page for the tab control. The case statements then do your
stuff for the controls inbdicated.

Get rid of the select statement and list all the if statements one after
the other. Then they will all be run when the tab chnages.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Jan 12 '06 #2
Thanks, that does work but I had to copy and paste all the controls and
the OnChange code into a new form. I think I had some other code
somewhere that was preventing me from accessing the other tabs in the
tab control.

thanks again,

Dave

Jan 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Phil | last post: by
1 post views Thread by Chattanooga | last post: by
5 posts views Thread by Dan Tallent | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.