Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking Form Controls

Status
Not open for further replies.

Reggaefloww

Programmer
Apr 8, 2006
16
US
I currently have the following code:

For Each ctl In Me.Controls
If ((ctl.Name = "PurchaseOrderNum") Or (ctl.Name = "ID")) Then
ctl.Locked = True
End If
Next ctl

For some reason, I'm getting a Microsoft Access runtime 438 error. It occurs at the ctl.Locked = True section. Can someone please let me know how to lock all form controls except for the control that has a specific name. The same code with MsgBox(Ctl.Name) replacing (ctl.Locked) works like a charm.

Thanks

Dee
 
Not all controls have a locked property but all have a name.
labels, command buttons, image controls, etc.

you need to test the control type first ex.
if ctl.controltype = actextbox then

or put an on error resume next
 
I see, lol

It looks like I'll have to owe you lunch or something. Thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top