Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Unanswered: Help with arrays

    I have a form with 5 labels on it.
    There are 3 users, each with a unique ID (from 1 to 3).

    I put the labels in an array together with the accessrights for each user,
    because depending on the UserID a label may be set visible or not.

    For example : see code below
    --> lbl_3 should be visible for user1, for user2 but not for user3.


    Code:
    dim arrLabels() as Variant
    dim element as Variant
    
        arrLabels = Array(lbl_1, True, True, True, _
                          lbl_2, True, True, True, _
                          lbl_3, True, True, False, _
                          lbl_3, True, True, False, _
                          lbl_4, False, False, False, _
                          lbl_5, True, True, True)
    
    for each element in arrLabels
           'HERE I NEED SOMETHING TO CHECK WETHER THE CURRENT USER IS ALLOWED TO SEE THE LABEL OR NOT
            element.visible = true
    next element
    How can I do this ?

  2. #2
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    Code:
       Dim arrLabels() As Variant
       Dim intArrayIndex As Integer
       Dim intCurrentUser As Integer
       Dim intUserCount As Integer
    
       intUserCount = 3   'total number of users
       intCurrentUser = 1 'current user
    
       arrLabels = Array(
          lbl_1, True, True, True, _
          lbl_2, True, True, True, _
          lbl_3, True, True, False, _
          lbl_3, True, True, False, _
          lbl_4, False, False, False, _
          lbl_5, True, True, True)
    
       ' hide/show appropriate information
       For intArrayIndex = 1 to UBound(arrLabels) Step intUserCount + 1
          Me(arrLabels(intArrayIndex)).Visible = Nz(arrLabels(intArrayIndex + intCurrentUser),0)
       Next

Posting Permissions

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