[AccessD] Looping through control names

Nancy Lytle lytlenj at yahoo.com
Fri Jul 16 12:47:40 CDT 2004


Thanks for the tips, actually I would like to combine
the two and have the validation at the end of the
form, listing all the fields that must be entered into
and those fields would have the background color
changed, ie Unfilled required fields would be yellow,
corrected field would again become transparent.  That
way one warning, and they can see all of their
"mistakes" at once.

Thanks for the ideas,
Nancy

--- Bob Gajewski <rbgajewski at adelphia.net> wrote:
> Nancy
> 
> 
> Two schools of thought:
> 
> 1) Let the user complete the form, and then validate
> it.
> 
> PROS: User allowed to input all data at one time,
> then
> 	validate entire form at end (during [Save] action
> 	or when leaving record?).
> 
> CONS: During validation, user receives error for
> EACH 
> 	empty field, corrects it, then validation routine
> 	must cycle through all controls again.
> 
> 2) Validate each field as completed using
> BeforeUpdate().
> 
> PROS: User stopped immediately and required to input
> 	data in empty field before advancing.
> 
> CONS: More coding required. Must account for user
> clicking
> 	around form, so may also need validation during
> 	OnBlur event.
> 
> 
> Regards,
> 
> Bob Gajewski
> 
> -----Original Message-----
> From: Nancy Lytle [mailto:lytlenj at yahoo.com]
> Sent: Friday, July 16, 2004 1:18 PM
> To: Access Developers discussion and problem Solving
> Subject: [AccessD] Looping through control names
> 
> 
> 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
> 
> -- 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> -- 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> 
> -- 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list