Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Sep 2006
    Location
    St. Augustine, Florida, USA
    Posts
    28
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Setting form tabs visible = Yes only when certain conditions present

    I have a form that identifies services provided to a client. There are multiple tabs on the form and some only apply to certain services. How can I hide that tab when it does not apply to the service displayed on the Parent form? I tried some VB code (I'm new at that) but it just hid the tab under all circumstances. Here's what I used:

    Private Sub Form_Open(Cancel As Integer)
    Dim intProgCode As Integer
    intProgCode = Me![PROGRAM CODE]
    If intProgCode <> 37 Then
    Page429.Visible = False
    End If

    End Sub

    Appreciate any help!
    M

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,435
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Madeline,

    With out more information I can only offer the following advice.
    Is the code segment above attached to the Main or Sub form? It should be in the main form and the Page429.visible prefixed by the sub form name. The code should also be located after the form is populated with data. If it is done before any data is entered on the form it will always default to hidden as you state. You should also attach a copy of the code to the AfterUpdate event of the "PROGRAM CODE" field so if it is changed the sub form page will become visible or invisible as the case applies.

    I hope this gives you some where to start. Maybe John H. or Mark L. will jump in with some more sage advice.

    Good Luck.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    Madeline (2011-06-14)

  4. #3
    Lounger
    Join Date
    Sep 2006
    Location
    St. Augustine, Florida, USA
    Posts
    28
    Thanks
    2
    Thanked 0 Times in 0 Posts
    This is definitely a good place to start. I'm still struggling with how everything should flow so your advice puts things in context. I'll let you know how it goes! Thanks again!
    Madeline

  5. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Quote Originally Posted by Madeline;805397
    Private Sub Form_Open(Cancel As Integer)
    Dim intProgCode As Integer
    intProgCode = Me![PROGRAM CODE
    If intProgCode <> 37 Then
    Page429.Visible = False
    End If

    End Sub
    In addition to the advice from Retired Geek, can I add that if you hide something you may also need to unhide again when you want to see it again.

    Code:
    If intProgCode <> 37 Then
    me.Page429.Visible = False
    else
    me.Page429.Visible = true
    End If
    This would ne needed if you were moving through records and you wanted the page to hidden or visible depending on the value of IntProgCode. In that circumstance, the code would need to be in the Current event for the form, so it executes each time you move from one record to another.

    A shorter way to write the same code is:

    Code:
    Me.Page429.Visible = (intProgCode = 37)
    Regards
    John



  6. The Following User Says Thank You to johnhutchison For This Useful Post:

    Madeline (2011-06-24)

  7. #5
    Lounger
    Join Date
    Sep 2006
    Location
    St. Augustine, Florida, USA
    Posts
    28
    Thanks
    2
    Thanked 0 Times in 0 Posts
    John,
    It worked!! Thank you so much!
    Madeline

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •