Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Short code (Access 2000)

    I have 6 controlss in the form called 1,2,3,4,5 and 6. Can i make them invisible with a short code ?

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

    Re: Short code (Access 2000)

    <code>Dim i As Integer
    For i = 1 To 6
    Me.Controls("[" & i & "]").Visible = False
    Next i</code>

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Short code (Access 2000)

    Thank you ! Thats what i wanted. How could i make a function out of it, called Private Function Visibility and change it for visible and invisible with one reference ?

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

    Re: Short code (Access 2000)

    You could use
    <code>
    Private Function Visibility(OnOff As Boolean)
    Dim i As Integer
    For i = 1 To 6
    Me.Controls("[" & i & "]").Visible = OnOff
    Next i
    End Function
    </code>
    To hide the controls:
    <code>
    Call Visibility(False)
    </code>
    To unhide them:
    <code>
    Call Visibility(True)</code>

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Short code (Access 2000)

    It is excellent what yo usuggested.I used it and it is very efficient.I wanted to repeat your suggestion with the labels from L1 to L12 but i got the message that the function is not supported. Why is it so ?
    Dim i As Integer
    For i = L1 To L3
    Me.Controls("[" & i & "]").Visible = False
    Next i
    End Function

  6. #6
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Short code (Access 2000)

    You are trying to use a string as an integer. You also do not reference the L# control. Your version references a numbered control.

    The following should work.

    Dim i As Integer
    For i = 1 To 12
    Me.Controls("[L" & i & "]").Visible = False
    Next i
    End Function

Posting Permissions

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