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

How to link text boxes on a subform to a tick box

I have created a database form that has subforms, on one of these subforms I want to be able tick the tick box so that it makes the text boxes appear so that information can be inputted. In the propert sheet I changed visibility to No to hide these boxes but do know how to make them reappear on the form when the tick box is ticked. Can anyone help?
Nov 26 '10 #1
5 1860
mshmyob
904 Expert 512MB
Assuming your check box and the controls you want to unhide are in your subform then you can put the following code in your AfterUpdate event of the check box:

Expand|Select|Wrap|Line Numbers
  1.     If Me.chkYourCheckBox.Value = True Then
  2.         Me.txtYourControlName.Visible = True
  3.     Else
  4.         Me.txtYourControlName.Visible = False
  5.     End If
  6.  
Don't forget to change the control names to what you have.

cheers,
Nov 26 '10 #2
Yeap! Welcome to bytes!!!!
Suppose you have the txtbox named [Fname] and optionButton named option7.
According to what I have understand, u want the OptionButton to decide on the visibility of the Fname txtbox depending on the Option7
If that is the case then do the following:
1. On the ONLOAD-Event property of a FORM, Use SETVALUE MACRO to set the property of [FName].[Visible]=No and Option7=0
2. On the AfterUpdate Event of a Option7 set to SETVALUE macro as If FName.Visible=Yes then turn it to No else turn it to Yes.
See the Attached DB below for more Clarifications
Attached Files
File Type: zip OptionBox.zip (22.0 KB, 72 views)
Nov 26 '10 #3
Or you may use this Code to set with VBA at the AfterUpdate Event of Option7
Expand|Select|Wrap|Line Numbers
  1. Private Sub Option7_AfterUpdate()
  2. If Me.FName.Visible = False Then
  3.         FName.Visible = True
  4.         Else: FName.Visible = False
  5. End If
  6. End Sub
  7.  
Nov 26 '10 #4
OldBirdman
675 512MB
Some points here:

1) The AfterUpdate Event occurs when the control loses FOCUS, so it does not occur when the 'Tick' box is 'Ticked', but when another control is selected, or the Enter or Tab key is pressed. So ticking the box will not cause the textbox to appear. It will take 2 steps. Better to use the OnClick event.

Expand|Select|Wrap|Line Numbers
  1. Private Sub chkYourCheckBox_Click
  2.     Me.txtYourControlName.Visible = Me.chkYourCheckBox
  3.     Me.txtYourControlName2.Visible = Me.chkYourCheckBox
  4.     Me.txtYourControlName2.Visible = Me.chkYourCheckBox
  5. End Sub
2) I would set the Enabled Property to True/False instead of the visible property. This would allow the operator to see what they were making available for use. When controls are not visible, a new operator may not find them. Visible but disabled shows them 'greyed-out' so the operator knows they exist: now only must figure out how to enable them.

3) If the subform View = Continuous Forms,
a) this will have to be done with Conditional Formatting. For Access 2003, the Enabled Property is available, but the Visible Property is not.
b) the tickbox will have to be bound to a table entry. An unbound control on a continuous form will change ALL the tickboxes when any one is ticked, and so Lock/Unlock or Show/Hide ALL the textboxes, not just the current record.

4) If the subform View = Single Form,
a) the tickbox my have to be set to False if not bound, and
b) the hidden/locked controls will retain the state of the previous record unless set in the OnCurrent Event.
Nov 26 '10 #5
mshmyob
904 Expert 512MB
I assumed this was on a continuous form since it does not work in a datasheet view.

The afterupdate event will fire in a continuous form and works as indicated. You may use the onclick event if you wish also.

The visible property is available as indicated in A2007.

As to using enabled or visible I will let the OP decide on that - but it is a valid point since it may not be a good idea to hide the controls from users but rather just disable them. If so just cahnge the visible property to enabled instead in the code.

The afterupdate will trigger as indicated but would not trigger if changes are made by code. Since we are not making changes to the control via code the afterupdate event will trigger by end user interaction.

cheers,
Nov 26 '10 #6

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

Similar topics

7
by: Gertjan van Heijst | last post by:
Hi, I really hope someone can help me because I've already spend 2 days on this problem and I'm not getting anywhere. I think the problem is that I don't really understand how text boxes store...
2
by: John Kreps | last post by:
(acc 2002) I've got six unbound text boxes on a subform that has a white background. Each of those six boxes has an expression that when true, will change its background from white to another...
4
by: godber | last post by:
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be...
1
by: khan | last post by:
I have a form sale and 2 subform on it,saledetail and services. On my sale form I have two text boxes txtTotalSale and txtserviceTotal. One is showing total from saledetail subform and other is...
9
by: ielamrani | last post by:
Hi, I am trying to color a subform tab blue or red when 2 of its text boxes are not null. Here is my code that I tried but it's not working: If Forms!.First Is Not Null And Forms!.Last Is Not...
2
by: NCRStinks | last post by:
Hello Sorry everyone, I am back again - I have tried to find the answer and after 2 hours of not getting anywhere I have finally given in. I have a form with several text boxes which are...
1
by: kickergirl | last post by:
I'm not sure my title actually describes my problem, but here it goes. I am creating a form to track account information for participants. Basically, a single participant can be offered up to...
11
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command...
3
by: Routergal | last post by:
I am trying to link a text box Employee ID (EMPLID) so that when the user enters the EMPLID the NAME appears in the second text box called NAME. Here is what I have so far...I keep getting runtime...
2
by: jimatqsi | last post by:
I'm getting "Application-Defined or object-defined error in procedure ..." sometimes, and sometimes not. This happens whenever I try to get the value from one of more of these text boxes on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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
jinu1996
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 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.