Gale Perez
galeper at gmail.com
Fri May 25 18:24:14 CDT 2007
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