1 to many dynamic controls

IGBP
01-02-2004, 11:09 PM
Hi everyone ...
I am dynamically adding Option buttons based on the result of a database query, and I am ending up with 1 extra control and it is the first record again :confused:
Here is the important code....

Do Until MyRS.EOF
strName = MyRS.Fields.Item("CompanyName").Value

Option1(i).Caption = strName

Load Option1(i + 1)
With Option1(i + 1)
.Top = Option1(i).Top + Option1(i).Height + 10
.Left = Option1(i).Left
.Visible = True
.Value = False
End With
i = i + 1
MyRS.MoveNext
Loop

Edit: The RecordCount is correct ..(6) but I end up with 7 option buttons
I have tried
Do ..
Loop Until
Do Until
Do While
Do While NOT ....

Any ideas ?
Thanks,
Michael

Dennis DVR
01-02-2004, 11:19 PM
try this.

Do Until MyRS.EOF
strName = MyRS.Fields.Item("CompanyName").Value

Option1(i).Caption = strName
With Option1(i)
If i > 0 Then
.Top = Option1(i-1).Top + Option1(i-1).Height + 10
.Left = Option1(i-1).Left
End If
.Visible = True
.Value = False
End With
i = i + 1
MyRS.MoveNext
If Not MyRS.EOF Then
Load Option1(i)
End If
Loop

IGBP
01-02-2004, 11:25 PM
Duane ...
That worked ...
Thank-you very much ;)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum