lock controls

  • Thread starter Thread starter alex
  • Start date Start date
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
 
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
 
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
 

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

Similar Threads

Lock VBA 9
Reference: many to one 8
Unlock new records? 3
lock/unlock controls 0
coding question - numbers 6
Delete Table 5
Locking controls in place in Design View 2
combo box locked 4

Back
Top