Array

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
 
A

Allen Browne

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
 
S

Snurre

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
 
A

Allen Browne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top