Josh McFarlane
darsant at gmail.com
Wed Jun 8 09:57:21 CDT 2005
On 6/8/05, paul.hartland at fsmail.net <paul.hartland at fsmail.net> wrote: > To all, > > I have a lot of text boxes, combo boxes and check boxes on a form and need them locked for certain users I tried the following code to loop through them and when txt, pv or chk is found to lock or disable the control but it doesn't work.... > > Dim intFields As Integer > For intFields = 0 To frmClient.Controls.Count > If (Left(frmClient.Controls(intFields).Name, 3) = "chk" Or Left(frmClient.Controls(intFields).Name, 3) = "txt") Then > frmClient(frmClient.Controls(intFields).Name).Locked = True > End If > If (Left(frmClient.Controls(intFields).Name, 2) = "PV") Then > frmClient(frmClient.Controls(intFields).Name).Enabled = False > End If > Next intFields > > can anyone tell me what I am doing wrong cause I can't seem to see the wood for the tree's at the moment... > > Thanks in advance for all your help... > > Paul Hartland Sorry I'm getting into this a little late. I think you might want to take a look into the tag property for controls. You label controls with any tags (or a number of tags) and then search for controls based on that tag, and disable / enable accordingly. This really comes in handy when different sets of controls need to be enabled / disabled for different states. Basic structure is a For Each statement. If you're interested I can give you a code sample. -- Josh McFarlane "Peace cannot be kept by force. It can only be achieved by understanding." -Albert Einstein