Results 1 to 7 of 7
  1. #1
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37

    Hide & unhide subform based on criteria of combo on main form

    I have a form named "frmquoteProject" which has a combo named "ProjectType" which pulls the list from a table.. If u select Wood for example I want to show a subform named "subfrm6ftprivacy" if you select anything else I want to hide the subform...



    Here is the code I put in afterupdate on the combo "ProjectType" and I know I cant use the ("me.visible = true") statement cause that would hide my main form.. What would I change this code to and hide the subform "subfrm6ftprivacy" upon selection and not the main form??

    Here is the code but not sure how to make it not me.visible and subform not visible instead..

    Code:
     
        Private Sub projecttype_AfterUpdate()
        If [ProjectType] = "Wood" Then
            subfrm6ftprivacy.Visible = True
     
        Else
     
     
     
        End If
     
     
    End Sub

    SOLUTION..................

    Code:
     
    Private Sub projecttype_AfterUpdate()
        If [ProjectType] = "Wood" Then
            Me.Controls("subfrm6ftprivacy").Visible = True
     
        Else
            Me.Controls("subfrm6ftprivacy").Visible = False
     
        End If
     
     
    End Sub
    Last edited by KLynch0803; 06-03-2009 at 09:36 AM. Reason: Solved

  2. #2
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    Have you tried this?


    Code:
    Private Sub projecttype_AfterUpdate()
        If [ProjectType] = "Wood" Then
            subfrm6ftprivacy.Visible = True
            
        Else
            
          subfrm6ftprivacy.Visible = False
                   
        End If
        
     
    End Sub

  3. #3
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37
    No sir that does not work it gives me Error 424

  4. #4
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    Works for me, have a look at the attached sample. I have 2 combo's one using primary key and the other using a "Value List" Text.

    If you select "Wood" in either it will hide the subform, then select paper in either and it will display the subform.

  5. #5
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37
    Heres what I ended up doing in it.. I have attached sample as well.. Seems to work fine and calculate also...

    Code:
     
    Private Sub Height_AfterUpdate()
         If [ProjectType] = "wood" And [Height] = "6" Then
                Me.Controls("subfrm6ftprivacy").Visible = True
                Me.Controls("subfrm4ftpicket").Visible = False
                Me.Controls("subfrm4ftchainlink").Visible = False
            ElseIf [ProjectType] = "wood" And [Height] = "4" Then
                Me.Controls("subfrm6ftprivacy").Visible = False
                Me.Controls("subfrm4ftpicket").Visible = True
                Me.Controls("subfrm4ftchainlink").Visible = False
        
            ElseIf [ProjectType] = "chain link" And [Height] = "4" Then
                Me.Controls("subfrm6ftprivacy").Visible = False
                Me.Controls("subfrm4ftpicket").Visible = False
                Me.Controls("subfrm4ftchainlink").Visible = True
        
            Else
                Me.Controls("subfrm6ftprivacy").Visible = False
                Me.Controls("subfrm4ftpicket").Visible = False
                Me.Controls("subfrm4ftchainlink").Visible = False
        End If
    End Sub
    Private Sub projecttype_AfterUpdate()
        
        If [ProjectType] = "wood" And [Height] = "6" Then
                Me.Controls("subfrm6ftprivacy").Visible = True
                Me.Controls("subfrm4ftpicket").Visible = False
                Me.Controls("subfrm4ftchainlink").Visible = False
            ElseIf [ProjectType] = "wood" And [Height] = "4" Then
                Me.Controls("subfrm6ftprivacy").Visible = False
                Me.Controls("subfrm4ftpicket").Visible = True
                Me.Controls("subfrm4ftchainlink").Visible = False
            
            ElseIf [ProjectType] = "chain link" And [Height] = "4" Then
                Me.Controls("subfrm6ftprivacy").Visible = False
                Me.Controls("subfrm4ftpicket").Visible = False
                Me.Controls("subfrm4ftchainlink").Visible = True
            
            Else
                Me.Controls("subfrm6ftprivacy").Visible = False
                Me.Controls("subfrm4ftpicket").Visible = False
                Me.Controls("subfrm4ftchainlink").Visible = False
        End If
        
     
    End Sub

  6. #6
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    Glad you go it working, I don't have 2007 installed so can't view your db.

    Do you have to reference controls in 2007 as?

    Code:
     Me.Controls("subfrm6ftprivacy").Visible = True
    in lieu of;

    Code:
    Me.subfrm6privacy.Visible = True

  7. #7
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37
    exactly how I did it yes....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Hide/UnHide forms
    By access in forum Forms
    Replies: 3
    Last Post: 06-03-2009, 07:48 AM
  2. Replies: 7
    Last Post: 05-24-2009, 10:24 AM
  3. Replies: 0
    Last Post: 08-17-2008, 12:19 PM
  4. Open form based on Subform criteria
    By Suzan in forum Programming
    Replies: 0
    Last Post: 04-25-2006, 02:28 PM
  5. Subform vs main form calculation
    By fadone in forum Forms
    Replies: 17
    Last Post: 12-21-2005, 07:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums