|
-
Nov 7th, 2000, 09:51 PM
#1
Thread Starter
Addicted Member
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)
-
Nov 8th, 2000, 05:04 AM
#2
Addicted Member
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.
-
Nov 8th, 2000, 10:04 PM
#3
Thread Starter
Addicted Member
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)
-
Nov 8th, 2000, 11:56 PM
#4
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|