473,408 Members | 2,839 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,408 software developers and data experts.

turn a control on, then off, on a form

139 100+
Hi there,

I have a button (cmdShowSearchButtons) on a form which, when clicked, makes two input boxes and two search buttons visible (ie `on`) - through the usual means of a click event.

However I want the button (cmdShowSearchButtons) to make these controls not visible when clicked again (ie 'off'). I'm sure I can do this through use of IF statements, but by golly, I can't get it to work...

Anyone who can point me in the right direction would be appreciated!

Thanks
Neil
Mar 12 '08 #1
6 2051
Scott Price
1,384 Expert 1GB
Posting your current code will help us out a bit!

The general idea is that you will use the If ... Then structure to first of all test whether the control is Visible. If [Control].Visible = False Then... Make it visible, otherwise make it invisible.

Regards,
Scott
Mar 12 '08 #2
missinglinq
3,532 Expert 2GB
Set the textboxes to Visible = No in the Property sheet.

In the cmdShowSearchButtons's Property Box, under the Caption Property type in Show Textboxes. Behind the Button's OnClick event, using the place this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdShowSearchButtons_Click()
  2.   If cmdShowSearchButtons.Caption =  "Show Textboxes" Then
  3.     cmdShowSearchButtons.Caption = "Hide Textboxes"
  4.     Me.YourTextboxNameHere.Visible = True
  5.   Else
  6.     cmdShowSearchButtons.Caption = "Show Textboxes"
  7.     AnyOtherControl.SetFocus
  8.     Me.YourTextboxNameHere.Visible = False
  9.   End If
  10. End Sub
I think I got this adapted right for your app. You just need to add all the textboxes/buttons you need to control in the same manner. If you have a problem let us know.

Because you can't hide a textbox that has focus, you need to use Line # 7 to move the focus to a control other than the ones you're hiding, to prevent an error from popping up.

Linq ;0)>
Mar 12 '08 #3
ndeeley
139 100+
Set the textboxes to Visible = No in the Property sheet.

In the cmdShowSearchButtons's Property Box, under the Caption Property type in Show Textboxes. Behind the Button's OnClick event, using the place this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdShowSearchButtons_Click()
  2.   If cmdShowSearchButtons.Caption =  "Show Textboxes" Then
  3.     cmdShowSearchButtons.Caption = "Hide Textboxes"
  4.     Me.YourTextboxNameHere.Visible = True
  5.   Else
  6.     cmdShowSearchButtons.Caption = "Show Textboxes"
  7.     AnyOtherControl.SetFocus
  8.     Me.YourTextboxNameHere.Visible = False
  9.   End If
  10. End Sub
I think I got this adapted right for your app. You just need to add all the textboxes/buttons you need to control in the same manner. If you have a problem let us know.

Because you can't hide a textbox that has focus, you need to use Line # 7 to move the focus to a control other than the ones you're hiding, to prevent an error from popping up.

Linq ;0)>

Worked like a charm!
Thanks Both!
Neil
Mar 13 '08 #4
Scott Price
1,384 Expert 1GB
Glad it works for you! Happy to help :-)

Regards,
Scott
Mar 13 '08 #5
I have a very similiar situation with a form, is it appropriate to post it here or start a new thread? It involves hiding/unhiding fields based on the selection of a value (case) from a list box.
Mar 14 '08 #6
missinglinq
3,532 Expert 2GB
You never go wrong starting your own thread!

Welcome to TheScripts!

Linq ;0)>
Mar 14 '08 #7

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

Similar topics

8
by: Michael Hill | last post by:
I have this input element: <input type='text' name='street' maxlength='20' size='20'> that I only want the user to be able to input to based on a item from a select list: <select...
3
by: Don | last post by:
Setting: chruch multimedia computer and projection system, with 2 display monitors. The projector is connected to monitor #2. Is there some way using JavaScript I can display a ".jpg" picture...
6
by: Debbie | last post by:
Hi Stephen, I'm trying to use your mousehook off...and thanks so much... it's such a blessing that you share with the rest of us. I have the dll in the same folder as the database and placed...
4
by: Bob | last post by:
Is there a way to turn off the form designer's automatic deletion of "handles <control>.<eventname>" when you delete a control? It's extremely annoying to replace one control with another of the...
1
by: Qwert | last post by:
Hello, when a NumericUpDown control has the focus, the mousewheel increases/decreases its value. How does one prevent this from happening? How does one turn off its mousewheel event? Thanks.
3
by: kolja2003 | last post by:
Hi, Is there somewhere the way to turn the any arbitrary DLL into control which I can put in my ToolBox and use further in my RAD development. I mean the way to create new control or component...
0
by: LeProgrammeur | last post by:
Hi guys! I created a control that works like an AJAX container. Basically the way it works is that all the ASP.NET controls that you place inside of the AJAX container will automatically become...
0
by: Ron | last post by:
Hi, I need to turn off my menu control when a user is in the process of changing there password. I know this can be done because the Login control automatically prevents the rendering of the...
1
by: robert112 | last post by:
Hi All, I have a webpage.aspx and a webusercontrol.ascx with both of them having viewstate turned off. Then in my web user control I have got some code reading the request stream: Dim str As...
0
by: robert112 | last post by:
Hi all, I have a WYSIWIG editor (fckeditor) and allow the users to create dynamic html which I save and display later on in the application. The aim is to have the user be able to create...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.