Array or controls on a form?

  • Thread starter Thread starter .Len B
  • Start date Start date
L

.Len B

I have a form with an option box containing 8 options for filtering
purposes.
Option Value 1 represents All
Option Value 2 represents Manager
Option Value 3 represents Keyworker etc.

The controls are named thus -
optRole1 lblRole1
optRole2 lblRole2 etc

Can I somehow change the names to
optRole(1) lblRole(1)
optRole(2) lblRole(2) etc

so that I can replace code like this
If mablnRoleActive(3) Then
lblRole3.BackColor = malngRoleBakGnd(3)
lblRole3.Caption = mastrRoleCaption(3)
Else
lblRole3.Visible = False
optRole3.Visible = False
End If
with a For / Next loop. In other words I want to change the left side of
the assignments to lblRole(x).property = ma...
 
Thanks Andre,
I'll try that technique.

Did you mean to repeat the same link or did you have another one in mind?
--
Len
______________________________________________________
remove nothing for valid email address.
| Yes, it can be done.
|
| See if this is of any assistance
| http://www.mvps.org/access/forms/frm0038.htm
|
| You may also want to look at
http://www.mvps.org/access/forms/frm0038.htm
|
| Andre
|
| | > I have a form with an option box containing 8 options for filtering
| > purposes.
| > Option Value 1 represents All
| > Option Value 2 represents Manager
| > Option Value 3 represents Keyworker etc.
| >
| > The controls are named thus -
| > optRole1 lblRole1
| > optRole2 lblRole2 etc
| >
| > Can I somehow change the names to
| > optRole(1) lblRole(1)
| > optRole(2) lblRole(2) etc
| >
| > so that I can replace code like this
| > If mablnRoleActive(3) Then
| > lblRole3.BackColor = malngRoleBakGnd(3)
| > lblRole3.Caption = mastrRoleCaption(3)
| > Else
| > lblRole3.Visible = False
| > optRole3.Visible = False
| > End If
| > with a For / Next loop. In other words I want to change the left side
of
| > the assignments to lblRole(x).property = ma...
| >
| > --
| > Len
| > ______________________________________________________
| > remove nothing for valid email address.
| >
| >
 
This worked a charm, thanks Andre

For I = 2 To conNumRoles
If mablnRoleActive(I) Then
Me("lblRole" & CStr(I)).BackColor = malngRoleBakGnd(I)
Me("lblRole" & CStr(I)).Caption = mastrRoleCaption(I)
Else
Me("lblRole" & CStr(I)).Visible = False
Me("optRole" & CStr(I)).Visible = False
End If
Next
and best of all, I didn't have to delete and recreate anything!
--
Len
______________________________________________________
remove nothing for valid email address.
| Yes, it can be done.
|
| See if this is of any assistance
| http://www.mvps.org/access/forms/frm0038.htm
|
| You may also want to look at
http://www.mvps.org/access/forms/frm0038.htm
|
| Andre
|
| | > I have a form with an option box containing 8 options for filtering
| > purposes.
| > Option Value 1 represents All
| > Option Value 2 represents Manager
| > Option Value 3 represents Keyworker etc.
| >
| > The controls are named thus -
| > optRole1 lblRole1
| > optRole2 lblRole2 etc
| >
| > Can I somehow change the names to
| > optRole(1) lblRole(1)
| > optRole(2) lblRole(2) etc
| >
| > so that I can replace code like this
| > If mablnRoleActive(3) Then
| > lblRole3.BackColor = malngRoleBakGnd(3)
| > lblRole3.Caption = mastrRoleCaption(3)
| > Else
| > lblRole3.Visible = False
| > optRole3.Visible = False
| > End If
| > with a For / Next loop. In other words I want to change the left side
of
| > the assignments to lblRole(x).property = ma...
| >
| > --
| > Len
| > ______________________________________________________
| > remove nothing for valid email address.
| >
| >
 
Back
Top