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

Subform does not hide/show depending on the checkbox value in main form.

P: 111
I have a table bound main form.It is a simple data entry form. It has 5 tabs and each tab contains a subform. There is a checkbox called chkShortRpt. I want something like this:
When user clicks on chkShortRpt, meaning it is true, I want to hide the third tab named SiteLocation and its subform.
How can I do it?
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkShortRpt_Click()
  2. If Me.chkShortRpt.Value = True Then
  3. Me.tabSite.Visible = False
  4. Else
  5. Me.tabSite.Visible = True
  6. End If
  8. End Sub
I tried to put the uppder code but what happens is:
1. When I open the form and if the first record has chkShortRpt=true, it won't hide the tab.
2. When I try to enter a new record, and make chkShortRpt= true, it will hide the tab temporarily. As soon as I click on any other tab it will show it again and it serves no meaning of the code than.

Please help!!
Mar 3 '10 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 100+
P: 2,321
Try putting your code into the AfterUpdate of the checkbox.
Mar 3 '10 #2

P: 111
Tried with no luck!!
any other solution?
Mar 3 '10 #3

Expert Mod 100+
P: 2,321
Have you tried stepping through the code, noticing when it fires, and what the values are?
Mar 3 '10 #4

P: 111
Yes I didFrom that I can say that the problem I think is where actually this piece of code should go? Under which event so that it refreshes the form back and forth depending upon the value in checkbox.
For ex. it would be wrong to put it uner Form's After or before update event as when again if someone opens a form it will show the tab. ( I tried that too) no matter what is the value in chekcbox.
Mar 3 '10 #5

Expert Mod 100+
P: 2,321
As far as I can see the best place to put it would be in the checkbox_AfterUpdate.
Mar 3 '10 #6

Post your reply

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