Results 1 to 3 of 3

Thread: Referencing a control?

  1. #1

    Thread Starter
    Lively Member Rockman's Avatar
    Join Date
    Apr 2001
    Posts
    66

    Question Referencing a control?

    I'd like to run 3 specific MSHFlexGrids through a for/next loop, but i don't know how to reference them correctly. Below is an example of what I am trying to do:

    Code:
    Dim cControl as MSHFlexGrid
    
      For i = 1 To 3
        If i = 1 Then
          cControl = Me.flxFindPhones
        ElseIf i = 2 Then
          cControl = Me.flxViewPhones
        ElseIf i = 3 Then
          cControl = Me.flxEditPhones
        End If
        With cControl
          .TextMatrix(0, 0) = "Type"
          .TextMatrix(0, 1) = "Number"
          .Row = 0
          For j = 0 To 1
            .Col = j
            .CellAlignment = flexAlignLeftCenter
          Next j
          .ColWidth(0) = 1920
          .ColAlignment(0) = flexAlignLeftCenter
          .ColWidth(1) = 2835
          .ColAlignment(1) = flexAlignLeftCenter
        End With
      Next i
    The code above chokes on "cControl = Me.flxFindPhones". Any other ideas out there?

    Thanks,
    Jeff

  2. #2
    AIS_DK
    Guest
    Since you are dealing with references you need to use the keyword set. Like this:
    Code:
    Dim cControl as MSHFlexGrid
    
      For i = 1 To 3
        If i = 1 Then
          Set cControl = Me.flxFindPhones
        ElseIf i = 2 Then
          Set cControl = Me.flxViewPhones
        ElseIf i = 3 Then
          Set cControl = Me.flxEditPhones
        End If
        With cControl
          .TextMatrix(0, 0) = "Type"
          .TextMatrix(0, 1) = "Number"
          .Row = 0
          For j = 0 To 1
            .Col = j
            .CellAlignment = flexAlignLeftCenter
          Next j
          .ColWidth(0) = 1920
          .ColAlignment(0) = flexAlignLeftCenter
          .ColWidth(1) = 2835
          .ColAlignment(1) = flexAlignLeftCenter
        End With
      Next i

  3. #3

    Thread Starter
    Lively Member Rockman's Avatar
    Join Date
    Apr 2001
    Posts
    66
    That's exactly the ticket AIS_DK!

    Thanks a bunch.

Posting Permissions

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



Click Here to Expand Forum to Full Width