[AccessD] OT - Looping Through Controls on Visual Basic Form

paul.hartland at fsmail.net paul.hartland at fsmail.net
Wed Jun 8 06:55:49 CDT 2005


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

-- 

Whatever you Wanadoo:
http://www.wanadoo.co.uk/time/

This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm


More information about the AccessD mailing list