473,396 Members | 1,846 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,396 software developers and data experts.

Hide and display subforms in tab conrol with checkbox

547 512MB
I have 2 different subforms in a tab control (TabCtl124).
When i open main form (RacesetupF), i would like 2 of the tab control and their subforms to be hidden except tabcontrol 1 and its subform as default.
I have a checkbox control called TimeCBox with the 3 different options.
The following code hide the Tab control on startup
Expand|Select|Wrap|Line Numbers
  1. Me.TabCtl124.Visible = false
then i will need code to call up
Expand|Select|Wrap|Line Numbers
  1.  Private Sub TimeCBox_Click()
  2. On Error GoTo TimeCBox_Click_Err
  3. If Forms![RaceSetupF]![TimeCBox] = 1 Then Me.TabCtl124.Pages(1).Visible = True
  4. If Forms![RaceSetupF]![TimeCBox] = 2 Then Me.TabCtl124.Pages(2).Visible = True
  5. If Forms![RaceSetupF]![TimeCBox] = 3 Then Me.TabCtl124.Pages(3).Visible = True
  6. TimeCBox_Click_Exit:
  7.     Exit Sub
  8. TimeCBox_Click_Err:
  9.     MsgBox Error$
  10.     Resume TimeCBox_Click_Exit
  11. End Sub
  12.  
AS you open one subform in checkbox, the others must be invisible

Please help it is not working.
Jan 16 '11 #1

✓ answered by mshmyob

Just reverse the order.

This assumes a triState checkbox.

Code for Onclick event of Checkbox
Expand|Select|Wrap|Line Numbers
  1.   If IsNull(TimeCBox) Then
  2.     Forms!RaceSetupF.TabCtl124.Pages(0).Visible = False
  3.     Forms!RaceSetupF.TabCtl124.Pages(1).Visible = False
  4.     Forms!RaceSetupF.TabCtl124.Pages(2).Visible = True
  5.   Else
  6.     Select Case TimeCBox
  7.  
  8.      Case Is = -1 ' checked
  9.         Forms!RaceSetupF.TabCtl124.Pages(0).Visible = True
  10.         Forms!RaceSetupF.TabCtl124.Pages(1).Visible = False
  11.         Forms!RaceSetupF.TabCtl124.Pages(2).Visible = False
  12.      Case Is = 0 ' unchecked
  13.         Forms!RaceSetupF.TabCtl124.Pages(0).Visible = False
  14.         Forms!RaceSetupF.TabCtl124.Pages(1).Visible = True
  15.         Forms!RaceSetupF.TabCtl124.Pages(2).Visible = False
  16.     Case Else
  17.      MsgBox ("Please make a selection")
  18.  
  19.     End Select
  20. End If
  21.  
Code for Onload event

Expand|Select|Wrap|Line Numbers
  1. Forms!RaceSetupF.TabCtl124.Pages(2).Visible = False
  2. Forms!RaceSetupF.TabCtl124.Pages(1).Visible = False
  3. Forms!RaceSetupF.TabCtl124.Pages(0).Visible = True
  4.  
cheers,

3 4772
neelsfer
547 512MB
I have changed the coding now for 2 tabs to be visible and disappear with the checkbox
I don't hide the tabs on load. it works now!
Expand|Select|Wrap|Line Numbers
  1. Private Sub TimeCBox_Click()
  2. On Error GoTo TimeCBox_Click_Err
  3. If Forms![RaceSetupF]![TimeCBox] = 1 Then
  4. Me.TabCtl124.Pages(0).Visible = True
  5. Me.TabCtl124.Pages(1).Visible = False
  6. End If
  7. If Forms![RaceSetupF]![TimeCBox] = 2 Then
  8. Me.TabCtl124.Pages(1).Visible = True
  9. Me.TabCtl124.Pages(0).Visible = False
  10. End If
  11. TimeCBox_Click_Exit:
  12.     Exit Sub
  13.  
  14. TimeCBox_Click_Err:
  15.     MsgBox Error$
  16.     Resume TimeCBox_Click_Exit
  17. End Sub
Jan 16 '11 #2
neelsfer
547 512MB
How can i make the following 2 tabs hidden on load of form
Expand|Select|Wrap|Line Numbers
  1. # Me.TabCtl124.Pages(0).Visible = False
  2. # Me.TabCtl124.Pages(1).Visible = False
i get a warning that you cant hide a control that has a focus
Jan 16 '11 #3
mshmyob
904 Expert 512MB
Just reverse the order.

This assumes a triState checkbox.

Code for Onclick event of Checkbox
Expand|Select|Wrap|Line Numbers
  1.   If IsNull(TimeCBox) Then
  2.     Forms!RaceSetupF.TabCtl124.Pages(0).Visible = False
  3.     Forms!RaceSetupF.TabCtl124.Pages(1).Visible = False
  4.     Forms!RaceSetupF.TabCtl124.Pages(2).Visible = True
  5.   Else
  6.     Select Case TimeCBox
  7.  
  8.      Case Is = -1 ' checked
  9.         Forms!RaceSetupF.TabCtl124.Pages(0).Visible = True
  10.         Forms!RaceSetupF.TabCtl124.Pages(1).Visible = False
  11.         Forms!RaceSetupF.TabCtl124.Pages(2).Visible = False
  12.      Case Is = 0 ' unchecked
  13.         Forms!RaceSetupF.TabCtl124.Pages(0).Visible = False
  14.         Forms!RaceSetupF.TabCtl124.Pages(1).Visible = True
  15.         Forms!RaceSetupF.TabCtl124.Pages(2).Visible = False
  16.     Case Else
  17.      MsgBox ("Please make a selection")
  18.  
  19.     End Select
  20. End If
  21.  
Code for Onload event

Expand|Select|Wrap|Line Numbers
  1. Forms!RaceSetupF.TabCtl124.Pages(2).Visible = False
  2. Forms!RaceSetupF.TabCtl124.Pages(1).Visible = False
  3. Forms!RaceSetupF.TabCtl124.Pages(0).Visible = True
  4.  
cheers,
Jan 16 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Targa | last post by:
I have a form in which I want to have an button(image) displayed next to a checkbox when it is checked. If the box is unchecked, the button should disappear. How can I do this? Thanks!
2
by: Pat Scott | last post by:
I am looking for a general purpose javascript snippet that enables me to <div> or <span> HTML to make portions of the form be hidden and then appear. The form contains about 12 sections and some...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
5
by: libsfan01 | last post by:
function switch_display(switchme) { var el = document.getElementById(switchme); el.style.display = (el.style.display == 'none')? '' : 'none'; } im using this function to switch the display on...
2
by: TGEAR | last post by:
there is one check box and if it is checked, then shows several fields underneath; otherwise, several fields are hidden. the default is unchecked. anyone can share the code for this function? ...
1
by: magix | last post by:
Hi, How can I used <DIVtag to display or hide certain code in html from javascript point of view ? <body onload="DisabledForm()" ...>
0
Denburt
by: Denburt | last post by:
This code is for a Toggle Button layout on a form, with this code you can set a number of toggle buttons visible and have multiple submenus that will stay hidden when not in use. My main menu is set...
1
by: aboon | last post by:
Hi I need help with showing field when checkbox checked and hiding field when the checkbox is unchecked. I was able to do it using dropdownlist but I'm not able to do it with checkboxlist at all....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.