473,320 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
2 3137
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kea | last post by:
I have a checkbox and a textbox in a continuous taborder on a form along with a bunch of other controls. The textbox is disabled. When I leave the checkbox I want to enable the textbox and move...
3
by: DBQueen | last post by:
I have a form with lines of controls. On some of the lines there are 3 controls (call them A,B,C); other lines have only control A. The controls have been numbered sequentially (Q20, Q21....Q76)...
1
by: @ndy | last post by:
Hi developers, i've a problem with my tabcontrol. Before i open my form with a tabcontrol with 3 tabs (Frm_Files|Frm_Lines|Frm_Guarantee) all the controls on al the tabs must be enabled. With...
2
by: buran | last post by:
Dear ASP.NET Programmers, I have a web user control (a search menu) which has 2 validation controls (one for input and another for the search criterion). I am including this search user control...
7
by: Phil | last post by:
on my form I have a checkbox and a tab control when the checkbox is true I wish to enable the controls on a single page of the tab control, is this possible or do I need to enable each control on...
1
by: Chattanooga | last post by:
hi all, is there a way to enable all controls in a web form? something like for each control in page.controls control.enabled = true next i tried the one above, but that did not give me...
1
by: danyeungw | last post by:
I get the following from the link http://support.microsoft.com/kb/314206. I need to have both work - the page stays where it is and set focus to next control. Does anyone have solution? I have...
3
AccessIdiot
by: AccessIdiot | last post by:
I was successful with help from another thread (this one ) in enabling and disabling a form/subform with a button. Essentially you press a button on the form and the form controls are disabled but...
5
by: Dan Tallent | last post by:
I have a scenerio when my forms are first opened that the user cannot modify the data. The fields are disabled to prevent them from modifying any of the data. If a user wishes to modify the...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.