By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

enable controls on tab control form

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.