Array

  • Thread starter Thread starter Snurre
  • Start date Start date
S

Snurre

Hi, is it possible to use an arry or somthing else for
this, I have lots of fields on a form (30-40), locking and
unlocking depending on users choice. After a while I must
reopen these fields again.

Me!Text28.Locked = True
Me!Text28.Enabled = True
Me!Text28.BackStyle = 1
Me!Text28.BackColor = vbWhite

Me!Text27.Locked = True
Me!Text27.Enabled = True
Me!Text27.BackStyle = 1
Me!Text27.BackColor = vbWhite

regards
Snurre
 
Dim strControlName As String
Dim i As Integer
For i = 27 to 28 'or whatever numbers you need
strControlName = "Text" & i
With Me(strControlName)
.Locked = True
.Enabled = True
.BackStyle = 1
.BackColor = vbWhite
End With
Next
 
What if numbers not in sequence or like this:

Me!MottattDato.Locked = True
Me!MottattDato.Enabled = True
Me!MottattDato.BackStyle = 1
Me!MottattDato.BackColor = vbWhite

Me!SykdomType.Locked = True
Me!SykdomType.Enabled = True
Me!SykdomType.BackStyle = 1
Me!SykdomType.BackColor = vbWhite


Snurre
 
Then you will need some way to identify these controls, such as putting
something in the Tag property. Then loop through all controls, and if it is
tagged, ...

For Each ctl In Me.Controls
If ctl.Tag = "Pick me!" Then ...
Next
 
Back
Top