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

Show/Hide ComboBoxe/s base on a tick box answer

5
Hello all,

A question from someone who dabbles in Access.
Is it possible to hide or ghost out a combo box (or set of them) on a Form, and only have them appear as a usable option if a tick box option that is also on the form is ticked or marked as true ??....

I am asking this as I want to prevent people entering the data into these combo boxes unless they have selected this tick box. I have a few queries that primarily look at the Yes/No option of the tick box when filtering information, and then subsequently pulls up the information to display from the field linked to the combo box/es.

I would imagine that it would be an after update event on the Tickbox command, if -1, show the combo boxes etc.

I hope that this gives enough information, if not,let me know and I will elaborate as required.

Thanks in advance for any assistance you are able to provide.

Cheers

TimC
Jul 6 '06 #1
7 9566
comteck
179 100+
The first thing you do is go into the properties for the combobox, and set "visible" to false. In the form's design view, right click on the combobox, and select properties. Scroll down to the "visible" field. While still in properties, change the name field to whatever name you want to call the combobbox. Close the combobbox properties.

Then you are going to create an event procedure for the check box. While still in design view for the form, right click on the checkbox and choose "Build Event", and select "Code Builder". The following code will appear:

Private Sub checkboxname_Click()

End Sub

For an example, if you named your combobox "Combobox1", then type the following code between the 2 lines:

Me.Combobox1.visible=True

So, it should now read:

Private Sub checkboxname_Click()
Me.Combobox1.visible=True
End Sub

Hope this works. Good Luck.
comteck
Jul 9 '06 #2
TimC
5
Thanks for the reply and information Comteck - much appreciated - and it is working as you thought it would.

It probably will work in it's current format - I'll have to test it on the labrats at work over the following couple of days.. :-) But if I may pursue this a bit further

Is it possible to expand the underlying code to keep the ComboBoxes visible once a true value is recorded on the Checkbox? (to allow these values to be seen if the information on the form is reviewed at a later time) - and I am shooting in the dark here when I write something like...

Private Sub EquipmentProblems_Check_BeforeUpdate() {Or ??which commmand}
If Me.EquipmentProblems_Check = True (?? or -1) Then
Me.Equip_Probs_1.Visible = True
Me.Equip_Probs_2.Visible = True
Me.Equip_Probs_3.Visible = True
End If
End Sub

I have tried the above code basically as formated above (and have removed the event procedurre for on Check_Click as it seemed to be messing with the above code - no errors though), but at this stage the code does not display the Combo boxes)

Any thoughts on this would be valued
Cheers
TimC
Jul 11 '06 #3
TimC
5
Mucking about with the code as below, it is nearly working how I thought I wanted it to... but it still requires a previuosly checked (true) checkbox to be unchecked and then checked to force the update and show the Comboboxes again

Private Sub EquipmentProblems_Check_BeforeUpdate(Cancel As Integer)

If Me.EquipmentProblems_Check = True Then
Me.Equip_Probs_1.Visible = True
Me.Equip_Probs_2.Visible = True
Me.Equip_Probs_3.Visible = True
End If
If Me.EquipmentProblems_Check = False Then
Me.Equip_Probs_1.Visible = False
Me.Equip_Probs_2.Visible = False
Me.Equip_Probs_3.Visible = False
End If

End Sub

Does anyone have a suggestion to get the combo boxes to show from the outset if the Checkbox is true (from an episode of previous data entry) for that particular record ?

Regards
TimC
Jul 11 '06 #4
comteck
179 100+
Is the checkbox bound to anything? If not, try adding a checkbox field in your table, and bound it to the checkbox on the form. You can then check for the value of the checkbox. You can still name the checkbox "EquipmentProblems_Check".

Instead of building the code on "Before Update", try opening the properties for the form, and using "On Current".
Also, I don't normally use If Then. I use Select Case wherever possible.

Private Sub EquipmentProblems_Check_OnCurrent(Cancel As Integer)
Dim selEquipProb as Boolean
selEquipProb=Me.EquipmentProblems_Check

Select Case selEquipProb

Case "True"
Me.Equip_Probs_1.Visible = True
Me.Equip_Probs_2.Visible = True
Me.Equip_Probs_3.Visible = True

Case "False"
Me.Equip_Probs_1.Visible = False
Me.Equip_Probs_2.Visible = False
Me.Equip_Probs_3.Visible = False

End Select

End Sub

If this doesn't work, then try adding a button, and using "On Click". In this case, the code would be created under the button instead of the checkbox.

Private Sub btnEquipmentProblems_OnClick(Cancel As Integer)
Dim selEquipProb as Boolean
selEquipProb=Me.EquipmentProblems_Check

Select Case selEquipProb

Case "True"
Me.Equip_Probs_1.Visible = True
Me.Equip_Probs_2.Visible = True
Me.Equip_Probs_3.Visible = True

Case "False"
Me.Equip_Probs_1.Visible = False
Me.Equip_Probs_2.Visible = False
Me.Equip_Probs_3.Visible = False

End Select

End Sub

Not sure if either of these will work. However, I'm quite sure you have the correct code.

Good Luck
comteck
Jul 11 '06 #5
TimC
5
Thanks Comteck,
I will give it a burl over the next day or so, and give you feedback on how it goes...

Just FYI - yes the checkbox is bound to in an underlying table (same as the combo boxes)....
Thanks for the tip for use of OnCurrent - It is these sort of things that you miss as a self taught Access user (and I really need to take a write VBA code course, as I tend to get lost in the heavy stuff from time to time. A mate that has been working on this project has more of a VBA brain than me, but we both are lacking when it comes to knowledge of the different VBA commands available).
I was using the If Then scavenged from some other code in the same form (that a 3rd person wrote in the database), threw it in to see if it would work :-P

So thanks again for the help

TimC
Jul 13 '06 #6
TimC
5
An update.....
The on current option - I couldn't seem to get it to work dynamically (ie update when flicking to the next form...) but putting the Select Case in place instead of the If staements still seemed to work a treat.

I'll probably leave it as it is now, as this is in escence what I was after (the ability for the dynamic update fits nicely in the obsesive/compulsive streak that I tend to get every now and then.... :-)

Thanks

TimC
Jul 17 '06 #7
ChaseCox
294 100+
The first thing you do is go into the properties for the combobox, and set "visible" to false. In the form's design view, right click on the combobox, and select properties. Scroll down to the "visible" field. While still in properties, change the name field to whatever name you want to call the combobbox. Close the combobbox properties.

Then you are going to create an event procedure for the check box. While still in design view for the form, right click on the checkbox and choose "Build Event", and select "Code Builder". The following code will appear:

Private Sub checkboxname_Click()

End Sub

For an example, if you named your combobox "Combobox1", then type the following code between the 2 lines:

Me.Combobox1.visible=True

So, it should now read:

Private Sub checkboxname_Click()
Me.Combobox1.visible=True
End Sub

Hope this works. Good Luck.
comteck

I found this comment very useful for what I wanted to do, which is hide pages on my form. I did however update the code, so that if the box is uncheked, the page will disapear.

Expand|Select|Wrap|Line Numbers
  1. Private Sub chkvoy2_AfterUpdate()
  2.  
  3.  If chkvoy2 = True Then
  4.         Me.Voyager2.Visible = True
  5.  Else
  6.         Me.Voyager2.Visible = False
  7.  
  8.  End If
  9. End Sub
  10.  
Where Voyager2 is my page name, and chkvoy2 is check box name.
Feb 6 '07 #8

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

Similar topics

6
by: C White | last post by:
Hi All It's been several years since I've done any ASP programming and I've recently been thrown back into it so I am very rusty, to say the least. I use a javascript, in regular html, you...
5
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main...
2
by: Flo | last post by:
Hello I want to be able to show/hide an application that is running. When i am getting the handles corresponding to an MS Office application (Excel for example), it appears that i get a handle...
3
by: Nathan | last post by:
I read an earlier post from Gary and answered by Peter Huang concerning closing one form and showing another. I need to do the same thing in my application, but the code Peter gave didn't work for...
4
by: Paul Wu | last post by:
Is there a way to constract a derived class that hides certain public members of a base class ? With the following code, a class that derives from DerivedClass can still see the member "Name" in the...
0
by: Lucian Wischik | last post by:
I'm using ToolTip.Show(x,y,..) to show my balloon-style tooltip at a specified coordinate. Most of the time it works fine and the "tip" of the balloon points exactly to my specified (x,y)...
1
by: Anne | last post by:
Hi, I have a gridview that display questions & answers. In some case the answers are text (up to 5000 char) and other cases they are tick boxes or numbers ($), or date. I have created 2...
17
by: may bailey | last post by:
Hi all, I have been trying to use a show / hide script on my web site but when I click on the "hide" button there occurs an error with explorer 7. The web site starts to go down =) and there...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.