PDA

View Full Version : Dynamically adding and positioning check boxes to wrap inside frame



talytech
07-17-2019, 05:48 AM
PLEASE HELP!! I have been struggling with positioning my check boxes inside a frame.
I have over 20 check boxes. I'm dynamically add them just fine. My problem comes when the number of checkboxes added is more than 10. After the 10th checkbox I'm unable to see the others. I know the problem is the position and I've applied code to handle when it is more than 5 for the 1st 10. But I need it to continue checking for after every 5. For example, I need 4 rows of checkboxes.. My code is below, which gives me 2 rows.



i = 1
c = 1

For each m In mailclass
Set chex = me.fr_mc.controls.add("forms.checkbox.1", m)
With chex
.caption = m
. Value = m
.width = 450
.height = 24

If c >5 then
L = 8
T = 20
Else
L = 0
T = 0
End If

.Left = 35 * (c - L - 1)
.Top = 0 + T

c = c + 1

i = i + 1

End With
Next


I can't figure out how to loop after the 10th check box is added.
Any help would be greatly appreciated as I've been at this for the past 2 weeks.

Bob Phillips
07-17-2019, 12:54 PM
i = 1
c = 1
T = -20 'adjust to set staring position as required

For Each m In mailclass

Set chex = Me.fr_mc.Controls.Add("forms.checkbox.1", m)

With chex

.Caption = m
.Value = m
.Width = 450
.Height = 24

If c Mod 5 = 1 Then

L = 5 'adjust to set staring position as required
T = T + 20
Else

L = L + 35
End If

.Left = L
.Top = T

c = c + 1
i = i + 1
End With
Next