Results 1 to 3 of 3

Thread: Labels inside Loop - correct syntax? _ RESOLVED

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    24

    Labels inside Loop - correct syntax? _ RESOLVED

    I need some help with the correct syntax.
    I have a form with ten labels, lbl1 - lbl10.

    I need to get ten records from a database and display each record in a label. I'm not sure of the correct way to do this.
    Thanks

    - - - - - -

    for i = 1 to 10

    Lbl "(i)" = rs("word")

    if not recordsetObject.EOF then
    RecordsetObject.movenext

    Else
    Exit For
    End if
    Next
    Last edited by pounce; Nov 19th, 2002 at 12:19 AM.

  2. #2
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Cool

    You need to create an array of labels. To do this simply set the index property of lbl1 to 0 and copy paste it ten times. then inside your code use:

    VB Code:
    1. for i = 1 to 10
    2.  
    3. Lbl1(i-1).Caption = rs("word")
    4.  
    5. ...
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    24

    Thanks!

    I give you all my points!

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