[AccessD] Looping through control names

Nancy Lytle lytlenj at yahoo.com
Fri Jul 16 12:17:42 CDT 2004


I am trying to make the users fill in a whole set of
fields when they do data entry - almost all fields in
the form must be filled in - this is a new
requirement.
I thought the easiest way would be to loop through the
controls that are mandatory (prefixed with mnd) and if
there is one that is null or an empty string to
require them to go back and fill it in.  
Where I am stuck is on checking the value of the data
in the control.  It doesn't like my code below.

I know I must be missing something simple but I can't
quite get it.
Any help appreciated.
Nancy

CODE:

Dim ctl As Control
For Each ctl In Forms!LCN1
'Find the mandatory fields
     If left(ctl.Name, 3) = "mnd" Then
'Check to see if the mandatory field is null

PROBLEM:"object required>
If ctl.Name.Value Is Null Then
END PROBLEM (I hope:))

'Tell them to go back and fill it in
            MsgBox "You must enter a value for the
field: " & ctl.Name
'            ctl.Name.SetFocus
            Exit Sub
            Else
'If it is not null then end
            End If
    Else
'if it is not mandatory
    End If
 Next
 'Check next control




More information about the AccessD mailing list