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

Active, Inactive textboxes

29
I have a form needs to be filled out. A lot of the questions are a yes/no question. When they pick yes I want some other textboxes to be active, and when they pick no I want the textboxes to be inactive. Example - A question could be: Do you have siblings. If you check yes, then other line would appear to say “How many” (other textboxes are active)? If you say no, then it skips to the next question (other textboxes are inactive - grayed out).
How do I do this? If it includes coding, can I get help with the coding?
Aug 6 '08 #1
20 4853
NeoPa
32,556 Expert Mod 16PB
It does include coding, but at what I would say is a fairly basic level.

Say you have a TextBox control [txtQ1] which expects either "Y" or "N". When the response "Y" is entered you want another TextBox [txtA1] to be enabled for input, but when the response "N" is entered you want TextBox [txtA1] to be disabled for input.

The following code could then be used to cause this to happen. This is called an Event Procedure and in this case it handles the AfterUpdate event for the [txtQ1] control.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtQ1_AfterUpdate()
  2.     Me.txtA1.Enabled = (Me.txtQ1 = "Y")
  3. End Sub
Aug 6 '08 #2
Scldb
29
It does include coding, but at what I would say is a fairly basic level.

Say you have a TextBox control [txtQ1] which expects either "Y" or "N". When the response "Y" is entered you want another TextBox [txtA1] to be enabled for input, but when the response "N" is entered you want TextBox [txtA1] to be disabled for input.

The following code could then be used to cause this to happen. This is called an Event Procedure and in this case it handles the AfterUpdate event for the [txtQ1] control.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtQ1_AfterUpdate()
  2.     Me.txtA1.Enabled = (Me.txtQ1 = "Y")
  3. End Sub


It does work but if I pick one record that is no, all textboxes going forward locked/grayed out. Can I have a code to reset on every new record
Aug 7 '08 #3
NeoPa
32,556 Expert Mod 16PB
It does work but if I pick one record that is no, all textboxes going forward locked/grayed out. Can I have a code to reset on every new record
I'm sorry I don't understand you :S

This isn't a continuous form is it?
Aug 7 '08 #4
Scldb
29
I'm sorry I don't understand you :S

This isn't a continuous form is it?
Let's hope this will clear it up:
Example: First question - Do you have any any siblings?
Second question - How many
I want the "How Many" question to be Disabled/Inactive until the first question is picked(yes).
Here is my actual code so far:
Expand|Select|Wrap|Line Numbers
  1. Sub txtIs_AfterUpdate() 
  2.   Me.txtApplication.Enabled = Me.txtIs 
  3. End Sub
What do I need in addition to the code to make this work? Thank you for your help.
Aug 7 '08 #5
NeoPa
32,556 Expert Mod 16PB
I think you copied the code down wrong.

Assuming the fields you've used match the correct controls, you need :
Expand|Select|Wrap|Line Numbers
  1. Sub txtIs_AfterUpdate() 
  2.   Me.txtApplication.Enabled = (Me.txtIs = "Y")
  3. End Sub
Aug 7 '08 #6
NeoPa
32,556 Expert Mod 16PB
...
Expand|Select|Wrap|Line Numbers
  1. Sub txtIs_AfterUpdate() 
  2.   Me.txtApplication.Enabled = (Me.txtIs = "Y")
  3. End Sub
What this is saying is :
  • Every time the operator makes a selection in Me.txtIs
  • First determine if Me.txtIs is "Y" or not (in the parentheses).
  • Assign this boolean (True/False) result to Me.txtApplication.Enabled.
Does that make better sense now?
Aug 7 '08 #7
Scldb
29
What this is saying is :
  • Every time the operator makes a selection in Me.txtIs
  • First determine if Me.txtIs is "Y" or not (in the parentheses).
  • Assign this boolean (True/False) result to Me.txtApplication.Enabled.
Does that make better sense now?
After applying this code, when I check the box - the textbox that I want to be enabaled is actually disabled (it was enable to start out which I want it disable until I check the box). Thank you for your help and hope you can still help me on this.
Aug 7 '08 #8
NeoPa
32,556 Expert Mod 16PB
You will probably need to provide some more info then. I'm running on air here nearly.

What type of control is txtIs (a TextBox I would guess)?
What's the exact question they are expected to answer?
Is the user entering "Y"? Maybe they enter "y"? Or "Yes" or something.

In any case, I think the code should probably change to the following so that we needn't care how they enter it :
Expand|Select|Wrap|Line Numbers
  1. Sub txtIs_AfterUpdate()
  2.   Me.txtApplication.Enabled = (UCase(Me.txtIs) = "Y")
  3. End Sub
Aug 7 '08 #9
Scldb
29
You will probably need to provide some more info then. I'm running on air here nearly.

What type of control is txtIs (a TextBox I would guess)?
What type of control is txtIs (a TextBox I would guess)?
Is the user entering "Y"? Maybe they enter "y"? Or "Yes" or something.

In any case, I think the code should probably change to the following so that we needn't care how they enter it :
Expand|Select|Wrap|Line Numbers
  1. Sub txtIs_AfterUpdate()
  2.   Me.txtApplication.Enabled = (UCase(Me.txtIs) = "Y")
  3. End Sub
To help you help me, here are the answers to you question:
What type of control is txtIs (a TextBox I would guess)? - Data type is Yes/No (so on the form all I get is a box to check)

What type of control is txtIs (a TextBox I would guess)? - I'm assuming that if a user checks the box this would be a "yes".

So txtIs is the checkbox for Yes/No and txtApplication is the next question that should only be active/enable if a user checks the txtIs checkbox. Also, I want txtApplication to be Inactive/Disabled when the user opens the form, right now it's active.
Aug 8 '08 #10
NeoPa
32,556 Expert Mod 16PB
Ah, it seems you are not yet aware WHY we preceed the name with things like "txt", "cbo", "bln" etc.

txtIs indicates that the control is a TextBox. For a Yes/No field you should use "bln" instead. Thus the control should be named [blnIs].

This explains why the code didn't work. The code was directed at a TextBox control.
...
What type of control is txtIs (a TextBox I would guess)? - I'm assuming that if a user checks the box this would be a "yes".
...
No! Most emphatically not.
Most can only return values of True or False (NB. Not strings "True" and "False", but boolean values which have numerical equivalents of -1 & 0 respectively).
...
Also, I want txtApplication to be Inactive/Disabled when the user opens the form, right now it's active.
...
I thought I'd already said to set this to Enabled=No in the design, but I checked the thread and it's not there anywhere - Ooops. That's what you need to do anyway.

Try this new code for your boolean (Yes/No) field (NB. The control should be renamed first to indicate the type) :
Expand|Select|Wrap|Line Numbers
  1. Sub blnIs_AfterUpdate()
  2.   Me.txtApplication.Enabled = Me.blnIs
  3. End Sub
Aug 8 '08 #11
Scldb
29
Thank very very much. It works.
Aug 11 '08 #12
NeoPa
32,556 Expert Mod 16PB
Very pleased to hear it and you're welcome :)
Aug 11 '08 #13
Scldb
29
Very pleased to hear it and you're welcome :)
Now I got another question related to this. The code that you gave me works but if I check yes (blnIS) for the active record that I'm on and then when I'm finished filling out the form and move on to the next form - the txtApplication is already active. It's suppose to be inactive/deactivated until the user checks yes (checks the blnIS checkbox).

The code that I'm using is:
Expand|Select|Wrap|Line Numbers
  1. Sub blnIs_AfterUpdate()
  2.   Me.txtApplication.Enabled = Me.blnIS
  3. End Sub
What additional code do I need.
Aug 12 '08 #14
NeoPa
32,556 Expert Mod 16PB
You need similar code in your Form_OnActive() event procedure.
Aug 12 '08 #15
Scldb
29
You need similar code in your Form_OnActive() event procedure.
Not following you on your statement there. Can you go more into detail.
Aug 12 '08 #16
NeoPa
32,556 Expert Mod 16PB
My bad! I meant OnCurrent not OnActive. Was rushing home at the time ;)

Something like the following :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me.txtApplication.Enabled = Me.blnIS
  3. End Sub
Obviously this would need to be handled for each such connected pair of controls on the form.

Is that a little clearer?
Aug 12 '08 #17
Scldb
29
My bad! I meant OnCurrent not OnActive. Was rushing home at the time ;)

Something like the following :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me.txtApplication.Enabled = Me.blnIS
  3. End Sub
Obviously this would need to be handled for each such connected pair of controls on the form.

Is that a little clearer?
Sorry, but I don't know where to find "OnCurrent" on the form. Can you please tell me how or where to go.
Aug 12 '08 #18
NeoPa
32,556 Expert Mod 16PB
Sure.
  1. Open the form in Design View.
  2. Right-click in an unused area of the grid (Not on any part of the form itself).
  3. Select Properties (if they are not already visible of course).
  4. In the Properties pane select either the Event or All tabs.
  5. Navigate to On Current.
  6. From the drop-down select [Event Procedure].
  7. Click on ellipsis button (...) to the right.
Bingo!
Aug 12 '08 #19
Scldb
29
Sure.
  1. Open the form in Design View.
  2. Right-click in an unused area of the grid (Not on any part of the form itself).
  3. Select Properties (if they are not already visible of course).
  4. In the Properties pane select either the Event or All tabs.
  5. Navigate to On Current.
  6. From the drop-down select [Event Procedure].
  7. Click on ellipsis button (...) to the right.
Bingo!
Got it. I click on the very little square on the top left side in Design View, went to properties and did what you said. IT WORKS WONDERFULLY. Thank you very much.
Aug 12 '08 #20
NeoPa
32,556 Expert Mod 16PB
"Oh ye of little faith!"

You sound surprised :D

Seriously, it's a pleasure to help.
Aug 12 '08 #21

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

Similar topics

0
by: Vesna Martinovic \(Dolenc\) | last post by:
Hello, Environment: db2 v7 on os/390 web service on win XP written in .net (Visual basic) We have a web service connects to db2 (ODBC) that leaves thread active. We did turn off...
2
by: Kelly | last post by:
I have a subform that display requisition information. One of the fields in the subform is a combo box that shows who requested the requisition. The users can change who requested the requisition...
2
by: Lenn | last post by:
Hello, This requirement might seem strange to someone out there, but here it's We need to make sure only certain number of users can be logged in the site at the same time. Is there any way to...
9
by: Laurent Bugnion | last post by:
Hi, I am wondering what is the best way to find out which ASP.NET sessions are still active. Here is the reason: I have a custom control which can upload files. It saves the files in a folder...
1
by: Fritjolf | last post by:
Hi. I'm developing a testapplication, retrieving objects of type "Computer" from out AD server. More than 5000 are listed, and I know lots of these are set as inactive. I've seen some code...
8
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the...
0
by: bisi | last post by:
Hello, I succeeded in adding a new user to the Active Directory using ldap_add, but by default, the new user is disabled(inactive). Is there any php-command to run or flag that I have to set to...
0
by: prashanthdb2 | last post by:
Hi, Im new to db2. Im using db2 ese 9.1 (fix pack 1) on SLES 9.0 32 bit. I have single instance on three logical nodes 0,1,2. i have cofigured userexit - on, logretain - on, trackmod - on. ...
3
by: pixiedust | last post by:
I have an employees table with a field called Status. It is a text field: Active or Inactive. Without changing it to a yes/no; is there a way to code so that if it says Inactive, that employee will...
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
marktang
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,...
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
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,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.