Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Thanked 0 Times in 0 Posts

    can i simplify a code (Access 2000)

    Can i simplify a code that makes visible different controls depending on the choice from the options in the
    main form? If in the main form the option 2 is chosen, then the visible control should be Sim and so on.
    Since i will add on further cases and options i would like to be independent of the hard coded enumeration of the cases.

    Public Function fpopup()
    Dim f As Form
    Set f = Forms![ProductsPopUp]
    Dim strDocName As String
    strDocName = "FOrderinformation"
    If IsOpen(strDocName) = True Then
    Select Case Forms![Classess]![Students]
    Case 1
    f![PopJohn].Visible = True
    Case 2
    f![Sim].Visible = True
    Case 3
    f![Kate].Visible = True
    Case 4
    f![Nina].Visible = True
    Case 5
    f![Steve].Visible = True
    Case 6
    f![Luke].Visible = True
    Case 7
    f![Bud].Visible = True
    End Select
    End If
    End Function

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Melbourne, Australia
    Thanked 27 Times in 27 Posts

    Re: can i simplify a code (Access 2000)

    Since you can reference f![PopJohn].visible as f("PopJohn").visible you could setup a table with 2 fields (CaseVal, & TextEquiv, TextEquiv could hold "PopJohn" in the case of CaseVal=2) etc.

    Alternatively, you could also setup an array and use the Case value ( Forms![Classess]![Students] ) as the index.

    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: can i simplify a code (Access 2000)

    If you're going to add lots of options, using a separate control for each option is probably not the optimal design. If you have 200 students, are you going to add 200 controls? Why not use one control? If you set up your tables and queries the right way, you can probably make it a bound control that automatically displays data for the right student. If that is not possible, you could change the contents or the control source of the control in code.

Posting Permissions

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