Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Box - True/False 1

Status
Not open for further replies.

regava

Programmer
May 24, 2001
152
US
How do I check for the value in a the check box for True/False? What I want to do is make another text box visible on TRUE or invisible on FALSE.
 
In the AfterUpdate event for the checkbox, put the following code:
Code:
If (Me![CheckBoxName] = True) Then
   Me![TextBoxName].Visible = True
Else
   Me![TextBoxName].Visible = False
End If
Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
Sorry, that code should have been:
Code:
If (Me![CheckBoxName]) Then
   Me![TextBoxName].Visible = True
Else
   Me![TextBoxName].Visible = False
End If
Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
Jonathan thank you for your help. I had tried every other event but the one you mentioned. I do appreciate it.
 
We used to get thoroughly told off for writing sloppy code like that in what is referred to as the old days.
What you should do is
[TextBoxName].Visible = [CheckBoxName]

Now that must be faster and easier to read. Peter Meachem
peter@accuflight.com
 
You're right, that is much cleaner, you do have a good point. Thanks for pointing that out in such a constructive and positive way. That makes me respect you so much more. Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
Peter thank you for your input. Your style is wonderful and faster in execution. However, been from the old days, if you do not document what you are doing, it could lead into a lot of trouble in the future.
 
From my point of view, the less you have to type the more readable the code and the less need to document. I must admit to only commenting complicated bits of code. The rule I use is to comment things I wouldn't understand 6 months later at 3 in the morning. Too many comments are just as bad as too few.
The equation I used is quite normal really. It you wanted
A.visible = ( B and C ) or D , then nobody (I hope) would attempt to write it using if then else. That would be terribly unreadable and prone to errors. You might calculate some right hand side expressions if, for example, B was complicated. So what is so odd about writing A.visible = B

A coding style forum, or something similar might be an idea. It appears to me that less emphasis is placed on good coding than it should be. Computers get faster all the time, so tend to mask the problems caused by coding errors. But you end up with a larger than necessary programme running more slowly than it ought.
Peter Meachem
peter@accuflight.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top