Is there anyone who can help me regarding the above subject?
My situation is that I have a field (with property set as as Yes/No) and I would like to use this to activiate the visibility of another field.
For example:
A student is a foreigner, he will mark the box checked (Are you a Foreigner?)then a label will appear beside it where he can put his nationality.
Thanks a lot...
7 16453 ADezii 8,834
Recognized Expert Expert
Is there anyone who can help me regarding the above subject?
My situation is that I have a field (with property set as as Yes/No) and I would like to use this to activiate the visibility of another field.
For example:
A student is a foreigner, he will mark the box checked (Are you a Foreigner?)then a label will appear beside it where he can put his nationality.
Thanks a lot...
Assuming your Controls are named chkForeigner and txtNationality, then, in the AfterUpdate() Event of chkForeigner: -
Private Sub chkForeigner_AfterUpdate()
-
If Me![chkForeigner] Then
-
Me![txtNationality].Visible = True
-
Else
-
'No Nationality should be listed if not a Foreigner
-
Me![txtNationality] = Null
-
Me![txtNationality].Visible = False
-
End If
-
End Sub
Additional points to consider:- The Visible Property of txtNationality should initially be set to No in the Control's Properties.
- For Viewing purposes, you may also wish to place this code in the Form's Current() Event. If the individual is a Foreigner, then the Nationality Text Box will be visible, if he/she is not, then it won't.
First off, your user cannot enter data in a "label box," data is entered in a textbox!
Place a textbox on your form.
Select it and goto Properties - Format and set the Visible Property to No.
Now place this code in the code module of your form: - Private Sub AreYouAForeignerCheckBox_AfterUpdate()
-
If AreYouAForeignerCheckBox = -1 Then
-
Me.NationalityTextBox.Visible = True
-
Me.NationalityTextBox.SetFocus
-
Else
-
Me.NationalityTextBox = ""
-
Me.NationalityTextBox.Visible = False
-
End If
-
End Sub
-
-
Private Sub Form_Current()
-
If AreYouAForeignerCheckBox = -1 Then
-
Me.NationalityTextBox.Visible = True
-
Else
-
Me.NationalityTextBox.Visible = False
-
End If
-
End Sub
-
This code does what you've requested and makes the textbox visible then sets focus on it, and if the user realizes that he/she has made a mistake and unchecks the box, it empties the data from the NationalityTextBox then makes it invisible again.
Welcome to TheScripts!
Linq ;0)>
Didn't mean to steps on your toes, ADezii! Clicked on Submit and took "Puck the Magic Chow Hound" out for his morning stroll, got back and saw that it had timed-out. Didn't think to see if anyone else had answered, just clicked again!
Linq ;0)> ADezii 8,834
Recognized Expert Expert
Didn't mean to steps on your toes, ADezii! Clicked on Submit and took "Puck the Magic Chow Hound" out for his morning stroll, got back and saw that it had timed-out. Didn't think to see if anyone else had answered, just clicked again!
Linq ;0)>
Never a problem, linq.
NeoPa 32,556
Recognized Expert Moderator MVP
You have two perfectly good examples of the type of code you need here. In essence, you simply set the .Visible property of your TextBox (not label) control to the CheckBox value. If the CheckBox is checked then .Visible will be set to TRUE, otherwise it will be set to FALSE.
ADezii 8,834
Recognized Expert Expert
You have two perfectly good examples of the type of code you need here. In essence, you simply set the .Visible property of your TextBox (not label) control to the CheckBox value. If the CheckBox is checked then .Visible will be set to TRUE, otherwise it will be set to FALSE.
Linq and I come from the same part of the Country, and consequently think alike to the point that it is almost scary! (LOL).
NeoPa 32,556
Recognized Expert Moderator MVP
Forget 'Almost' ADezii ;)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dcstech |
last post by:
I have a label that will not display. On the form load event I wrote
"label1.visible=false".
when my routine get at the end of the code I inserted "label1.visible=true".
I have had a similar...
|
by: PCB |
last post by:
Hi all,
Not sure if this is possible, but can I change the controls of a
command button on a per record bases in a subform. In my case, I would
like to make a command button visible only if...
|
by: Susan Bricker |
last post by:
Greetings. I have three forms that are open at the same time. They are
related and cascading. The first form (frmEventAdd) is the anchor. Each
event can have many Trials. The second form is...
|
by: Dave |
last post by:
I have a button on Form1 that hides the form and displays Form2:
Form2 myForm2 = new Form2();
myForm2.Show();
this.Hide();
After I do some work in Form2 I want to close it and redisplay...
|
by: M Shafaat |
last post by:
Hi!
How can I make label, linklabel . controls to accept multilined text at
design time and in the properties window of Visual Studio?
Regards
M Shafaat
| |
by: Gibs |
last post by:
Hi,
How can i make a label visible/invisible? I am able to do it for text box by
using document.form1.TextBox1.style.visibility="hidden"; But when i am
giving the same for the label, i am getting...
|
by: Selden McCabe |
last post by:
I have a form with a bunch of image buttons. When the user moves the mouse
over a button, I want to do two things: 1. change the Imagebutton's picture,
and 2. make another control visible.
I'm...
|
by: Beffmans |
last post by:
hi
I am trying to make this label visible through a checkbox. I try to make
use of javascript but what am I doing wrong?
<HTML>
<HEAD>
<title>WebForm1</title>
<script>
|
by: stevewy |
last post by:
If I am using srcElement (or "target" for non-IE models) to return
various properties of an object I have clicked on, can I access for
"label for" value in any way? I'm thinking, for example, of...
|
by: pradeep |
last post by:
how to set input type label's value through javascript
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
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,...
|
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...
|
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...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |