Results 1 to 4 of 4
  1. #1
    Bill Neilsen is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2014
    Location
    Perth
    Posts
    3

    How to hide controls (Tab control)

    Hi guys,

    My main form has a combo box that lists the type of equipment for the particular record, eg T50, T100 and T320

    The main form also has 3 tab controls, page 33, page 34 and page 35 and these tabs each have subforms for tasks on particular pieces of equipment eg T50, T100 and T320.

    How can I show just the tab for the T50 when the combo box shows T50, and hide the other tabs?

    And also show just the T100 tab when the combo shows T100, etc.

    Thanks in advance.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Example from my code:
    Code:
    Private Sub ShowTabs()
    With Me
    .tbxSet = TestSet(.tbxLABNUM, "Soils & Aggregate")
    .pge1.Visible = True
    .pge2.Visible = True
    .pge3.Visible = True
    .pge4.Visible = True
    .pge5.Visible = True
    .pge6.Visible = True
    .tbxLABNUM.SetFocus
    
    'use Val to capture characters preceeding :### which will be present if gradation test selected
    If Not Val(.tbxSet) Like "*1*" Then
        .pge1.Visible = False
    End If
    If Not Val(.tbxSet) Like "*2*" Then
        .pge2.Visible = False
    End If
    If Not Val(.tbxSet) Like "*3*" And Not Val(.tbxSet) Like "*E*" Then
        .pge3.Visible = False
    End If
    If Not .tbxSet Like "*P*" Then
        .pge4.Visible = False
    End If
    If Not .tbxSet Like "*V*" Then
        .pge5.Visible = False
    Else
        .pge2.Visible = False
    End If
    If Not .tbxSet Like "*H*" Then
        .pge6.Visible = False
    End If
    
    If .pge6.Visible Then
        .pge6.SetFocus
    ElseIf .pge1.Visible Then
        .pge1.SetFocus
    ElseIf .pge2.Visible Then
        .pge2.SetFocus
    ElseIf .pge3.Visible Then
        .pge3.SetFocus
    ElseIf .pge4.Visible Then
        .pge4.SetFocus
    ElseIf .pge5.Visible Then
        .pge5.SetFocus
    End If
    End With
    End Sub
    You could try code like:
    Me.pgT50.Visible = (Me.combobox = "T50")
    Me.pgT100.Visible = (Me.combobox = "T100")
    Me.pgT320.Visible = (Me.combobox = "T320")

    Be aware that at least one page must always be visible.
    Last edited by June7; 07-20-2014 at 12:35 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Posts
    528
    It can also use the following line
    After update
    Dim R As String
    R = Combo
    Me.RecordSource = "SELECT tblName.* FROM tblName WHERE (((tblName.FieldName)='" & [Forms]![frmName]![Combo] & "')); "
    Combo = R

  4. #4
    Bill Neilsen is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2014
    Location
    Perth
    Posts
    3
    Hi guys,

    I'm nearly there, the code I ended up using in the "On Current" property of the form is below.
    And, it works for current records, but not for new a new record.
    When I put in a new record, no changes, but if I roll out of and back into the record it works.
    Is there some code I should be putting in the properties of the combo box "Type"?
    Private Sub Form_Current()
    If Me.Type = "2" Then
    Me.Page33.Visible = True
    Me.Page34.Visible = False
    Me.Page54.Visible = False
    End If

    End Sub

    Thanks guys.

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

Similar Threads

  1. web browser control (hide the website name)
    By wnicole in forum Access
    Replies: 1
    Last Post: 12-05-2013, 03:49 AM
  2. Show/Hide Page Control
    By RLJ in forum Forms
    Replies: 1
    Last Post: 02-04-2013, 10:48 AM
  3. Open Report and Hide Control using VBA
    By tylerg11 in forum Reports
    Replies: 4
    Last Post: 08-09-2012, 12:42 PM
  4. Hide each control, control group or subform?
    By BRV in forum Programming
    Replies: 2
    Last Post: 12-09-2011, 09:36 AM
  5. Combobox-dependent show/hide controls
    By focosi in forum Forms
    Replies: 3
    Last Post: 07-31-2011, 06:47 AM

Tags for this Thread

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