Results 1 to 4 of 4

Thread: Data Repeater Look-alike

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Posts
    230
    Say I have an undetermined amount of records returned from a query.I want to create textboxes, checkboxes, etc. on the fly for the correct number of records. Is there a way to place controls on a form at runtime without having to pile a buch of invisible ones on form and then making them visible. The result would be like the data repeater control, but I only have the option of DAO. I think the data repeater only works with ADO.

    Shawn Hull
    VB6, SP3 (Professional Edition)

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    Use an object array and a code similar to this:

    Code:
    -------------------------------------------------------
    ¡® Create a control, say a textbox, in advance and set the index as 0
    ¡® rs is your recordset
    ¡® 300 is the vertical space as you wish between textboxes

    Dim intNumOfRecord As Integer
    Dim i As Integer
    intNumOfRecord = rs.RecordCount

    For i = 1 To (intNumOfRecord ¨C 1)
    Load Text1(i)
    With Text1(i)
    .Top = Text1(i - 1).Top + 300
    .Visible = True
    End With
    Next

    For i = 0 To (intNumOfRecord ¨C 1)
    Text1(i).Text = rs.Fields(0)
    rs.MoveNext
    Next
    ------------------------------------------------------

    Hope it helps.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Posts
    230

    I like it

    This is clever. Thanks a bundle, I thought I was going to have to put a bunch of invisible text controls on the form.

    Can I do this with any control?

    Shawn Hull
    VB6, SP3 (Professional Edition)

  4. #4
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    I am glad you like it.
    I think you can do that with many, if not any, controls, such as command controls, picture boxes, labels, etc.

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