Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Indentify Groups of Controls (2003 SP3)

    I have a form with nearly 500 objects and I need to make specific groups visible or not visible according to the contents of one of the combo boxes. I thought I could name each control with a number, for example, 9txtName and 9lblName, so that I could nominate to have all objects with a prefix of 9, 10 and 11 be visible and others prefixed with 6, 7, and 8 be invisible. I did this once when there was only 50 controls on the form but with 18 groups, hopefully there is an easier way than this ...

    Dim ResultsBC As Form

    If ResultCol = "Notes" Then
    ResultCol = 1
    End If

    Set ResultsBC = Form_frmSectionB_Notes

    With ResultsBC
    Select Case ResultCol
    Case 1 ' Start
    .Ctl1txtName.Visible = True
    .Ctl1txtSuburb.Visible = True
    .Ctl2txtZip.Visible = True
    .Ctl2cboState.Visible = True
    .Ctl3rctSurround.Visible = True
    .Ctl4cmdClose.Visible = True
    Case 2 ' Stage 1
    .Ctl1txtName.Visible = True
    .Ctl1txtSuburb.Visible = True
    .Ctl2txtZip.Visible = False
    .Ctl2cboState.Visible = False
    .Ctl3rctSurround.Visible = False
    .Ctl3cmdClose.Visible = False
    Case 3 ' Stage 2, 3
    .Ctl1txtName.Visible = False
    .Ctl1txtSuburb.Visible = False
    .Ctl2txtZip.Visible = False
    .Ctl2cboState.Visible = False
    .Ctl3rctSurround.Visible = True
    .Ctl3cmdClose.Visible = True
    Case 4 ' Stage 4. 8. 12 etc
    .Ctl1txtName.Visible = False
    .Ctl1txtSuburb.Visible = False
    .Ctl2txtZip.Visible = True
    .Ctl2cboState.Visible = True
    .Ctl3rctSurround.Visible = False
    .CtlcmdClose.Visible = False
    Case 5 ' Stage 5, 6, 7, 9, 10, 11 etc
    Case Else
    End Select
    End With
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Indentify Groups of Controls (2003 SP3)

    I don't see much of a pattern in the code.
    You could set the Tag property of each control to reflect the cases it belongs to, and do something like this:

    Dim ctl As Control
    For Each ctl In ResultsBC.Controls
    ' Some kind of condition on the tag depending on the stage
    If ctl.Tag = ... Then
    ctl.Visible = True
    Else
    ctl.Visible = False
    End If
    Next ctl

    A better approach might be to create a tab control and place the controls on tab pages. Activate a tab page depending on the stage. Access automatically displays only the controls on the active tab page.

Posting Permissions

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