Locked/Enable multiple fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there an easy way to set the "locked" and "enabled" properties of multiple
fields on a form:

Me.HouseID.Locked=True
Me.HouseName.Locked=True
Me.HouseAddLine1.Locked=True
etc

Many thanks
Scott
 
Scott,

The answer is yes, if you can somehow logically group the controls you
want to lock. For instance, the following will lock all controls whose
name starts with House:

For Each ctl In Me.Controls
If Left(ctl.Name, 5) = "House" Then ctl.Locked=True
Next

Alternatively, the following will lock all tetxboxes regardless of name:

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then ctl.Locked=True
Next

HTH,
Nikos
 
Back
Top