Trying something but not working, please help!

G

Gina Whipp

Hey all,

As opposed to typing...

If Not IsNull(txt1Label) Then
.txt1Label.Locked = True
Else
.txt1Label.Locked = False
End If

9 times I tried to have it loop thru the text fields and lock the ones
containing text but it's not working. It only locks the first one and
forgets about the other 8. Do I have to do it the long way and forget about
my idea?

Thanks to all who offer some insight...
Gina Whipp


Dim LabelNumber As Long

LabelNumber = 0

Do Until LabelNumber > 9
LabelNumber = LabelNumber + 1
Loop

If LabelNumber > 9 Then 'Stops cycling after 9 resets to 0
LabelNumber = 1
End If

If Not IsNull(Me("txt" & LabelNumber & "Label")) Then
Me("txt" & LabelNumber & "Label").Locked = True
'Else
'Me("txt" & LabelNumber & "Label").Locked = False
End If
 
A

Allan Murphy

Gina

Try putting the IF Then Else End if inside the DO Loop

Dim LabelNumber As Long

LabelNumber = 1

Do Until LabelNumber > 9

If Not IsNull(Me("txt" & LabelNumber & "Label")) Then
Me("txt" & LabelNumber & "Label").Locked = True
' Else
'Me("txt" & LabelNumber & "Label").Locked = False
End If

LabelNumber = LabelNumber + 1

Loop
 

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