lock controls

A

alex

Hello All,

In VBA, is there a way to lock/unlock all bound controls at once, or
do I have to name them individually?

alex
 
D

Douglas J. Steele

You can set the form so that it doesn't allow edits, deletions or inserts.
Would that be sufficient?

If not, you can loop through all of the controls, check whether they're
bound, and lock that way:

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If Len(ctlCurr.ControlSource) > 0 Then
ctlCurr.Lock = True
End If
Next ctlCurr
 
A

alex

You can set the form so that it doesn't allow edits, deletions or inserts.
Would that be sufficient?

If not, you can loop through all of the controls, check whether they're
bound, and lock that way:

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If Len(ctlCurr.ControlSource) > 0 Then
ctlCurr.Lock = True
End If
Next ctlCurr

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)








- Show quoted text -

Thanks Doug for your help.

I need to leave the form editable because I have an unbound combo box
that functions as a look up.
I'll give the loop a try.

alex
 
Top