[AccessD] Error 3314 (required field) - trap in form_error

Dan Waters dwaters at usinternet.com
Fri May 25 19:24:04 CDT 2007


Hi Gale,

In addition to checking for Null, you also must check for an empty string.

    If IsNull(ctl) or ctl = "" Then

If you want, you can place a value in a control's Tag property, such as R or
Required to designate that field as required.  But if every control that has
a caption is actually required, then I think your method is appropriate.

Also, I would recommend going through this loop before an error occurs, if
you can.

HTH,
Dan

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gale Perez
Sent: Friday, May 25, 2007 6:24 PM
To: accessd at databaseadvisors.com
Subject: [AccessD] Error 3314 (required field) - trap in form_error

Hi!

I have a form with several fields whose "Required" property is Yes, and
I want to trap Error 3314 (required field) in the form_error.  I would like
the code to set focus on the first field that is required and null and
display a custom message.  The problem is that it isn't seeing the control
as Null (so it ignores If IsNull(ctl), and just displays the customary
message).  I would greatly appreciate any advice.

I am also interested in finding out if you can determine a control's
table-level properties (e.g., required, and datatype) while in the form,
instead of using an asterisk and looking at the label caption to do it.
Here is the code:

Dim ctl as Control
Dim strCaption as String
......
If DataErr = 3314 Then
     For Each ctl In Me.Controls
          ' get the caption for the field label
          strCaption = Screen.ActiveControl.Controls.Item(0).Caption
          If Left(strCaption, 1) = "*" Then          'required field
               If IsNull(ctl) Then  'it is ignoring this, not seeing the
field as null
                    ctl.SetFocus
                    MsgBox Chr$(34) & strCaption & Chr$(34) & " is a
required field."
                    Response = acDataErrContinue
                    Exit sub
                End If
          End If
     Next
End if

Thank you so much for any assistance,
Gale
-- 
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