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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AccessBeetle
    New Member
    • Jul 2009
    • 111

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

    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?
    Code:
    Private Sub chkShortRpt_Click()
    If Me.chkShortRpt.Value = True Then
    Me.tabSite.Visible = False
    Else
    Me.tabSite.Visible = True
    End If
    
    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=tru e, 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!!
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Try putting your code into the AfterUpdate of the checkbox.

    Comment

    • AccessBeetle
      New Member
      • Jul 2009
      • 111

      #3
      Tried with no luck!!
      any other solution?

      Comment

      • TheSmileyCoder
        Recognized Expert Moderator Top Contributor
        • Dec 2009
        • 2322

        #4
        Have you tried stepping through the code, noticing when it fires, and what the values are?

        Comment

        • AccessBeetle
          New Member
          • Jul 2009
          • 111

          #5
          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.

          Comment

          • TheSmileyCoder
            Recognized Expert Moderator Top Contributor
            • Dec 2009
            • 2322

            #6
            As far as I can see the best place to put it would be in the checkbox_AfterU pdate.

            Comment

            Working...