By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,460 Members | 2,215 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,460 IT Pros & Developers. It's quick & easy.

How to make a checkbox hide a field in subform on a tab control

100+
P: 547
I have been struggling for 4 hours now with this. When i click the checkbox, it is suppose to hide a specific field [NPItemtype] in a subform [NPCaptOtherSF] which is situated on a tab control with other subforms
(columns = option group for checkbox)
i have tried the following:
Expand|Select|Wrap|Line Numbers
  1. If Forms![fis_npcaptureF]![Columns] = 1 Then [Forms]![fis_npcaptureF]![NPCaptOtherSF]![NPItemtype].ColumnHidden = True
  2. else
  3. [Forms]![fis_npcaptureF]![NPCaptOtherSF]![NPItemtype].ColumnHidden = False
  4.  
also tried
Expand|Select|Wrap|Line Numbers
  1. If Forms![fis_npcaptureF]![Columns] = 1 Then [Forms]![fis_npcaptureF]![NPCaptOtherSF]![NPItemtype].visible = false
  2. else
  3. [Forms]![fis_npcaptureF]![NPCaptOtherSF]![NPItemtype].visible = True
I am not sure whether it is the Tab control affecting it.
Please be so kind to assist.
Apr 21 '12 #1

✓ answered by NeoPa

To start with, all references should be relative to the Me reference.

For the basic information from which you should be able to determine this for yourself, see Referring to Items on a Sub-Form.

I'll assume, from what's in your question, that the following is an accurate description of what you're working with :
  • Name of main form = [fis_npcaptureF].
  • Name of CheckBox control = UNKNOWN. I will refer to it for now as [chkVis].
  • Name of option group in which [chkVis] seems to have a value of 1 = [columns].
  • Name of Tab (or Page) control = UNKNOWN. Also irrelevant so I will not refer to it at all.
  • Name of the subform control on the Tab (or Page) = [NPCaptOtherSF].
  • Name of control on the form, within the subform control, that you intend to show/hide = [NPItemtype].

Unfortunately, I have no info as to whether or not anything is bound, so I will assume for now that it is. An unbound form would not require a Form_Current() event procedure.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Call ShowHide()
  3. End Sub
  4.  
  5. Private Sub columns_AfterUpdate()
  6.     Call ShowHide()
  7. End Sub
  8.  
  9. Private Sub ShowHide()
  10.     With Me
  11.         .NPCaptOtherSF!NPItemtype.Visible = Not .chkVis
  12.     End With
  13. End Sum

Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,398
To start with, all references should be relative to the Me reference.

For the basic information from which you should be able to determine this for yourself, see Referring to Items on a Sub-Form.

I'll assume, from what's in your question, that the following is an accurate description of what you're working with :
  • Name of main form = [fis_npcaptureF].
  • Name of CheckBox control = UNKNOWN. I will refer to it for now as [chkVis].
  • Name of option group in which [chkVis] seems to have a value of 1 = [columns].
  • Name of Tab (or Page) control = UNKNOWN. Also irrelevant so I will not refer to it at all.
  • Name of the subform control on the Tab (or Page) = [NPCaptOtherSF].
  • Name of control on the form, within the subform control, that you intend to show/hide = [NPItemtype].

Unfortunately, I have no info as to whether or not anything is bound, so I will assume for now that it is. An unbound form would not require a Form_Current() event procedure.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Call ShowHide()
  3. End Sub
  4.  
  5. Private Sub columns_AfterUpdate()
  6.     Call ShowHide()
  7. End Sub
  8.  
  9. Private Sub ShowHide()
  10.     With Me
  11.         .NPCaptOtherSF!NPItemtype.Visible = Not .chkVis
  12.     End With
  13. End Sum
Apr 21 '12 #2

Post your reply

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