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

Dan Waters dwaters at usinternet.com
Tue May 29 17:13:32 CDT 2007


Hi Gale,

In the Enter event for a combobox, do this:

	If IsNull(cboList) then
		cboList.Dropdown
	End If

This means that anytime the user tabs into this combobox and it's empty, the
list drops down automatically (or if you use cboList.SetFocus after finding
that it's required but empty).

Dan


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gale Perez
Sent: Tuesday, May 29, 2007 4:00 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Error 3314 (required field) - trap in form_error

Hi again!

I tried Steve's method as I was hoping for a quick fix.  It works great,
although I had a few things I wanted to do that I may not be able to with
this method.  One thing is that I'd like to set focus on the required field
after the message, and to drop down if it's a combo box.  I'd also like to
replace the standard Access title in the message box with my own, and I
don't know if that's possible using this method without writing a function
containing the validation rule & text and the components of the message
box.

The third thing is a form-subform problem:  I'm using a subform and although
the Validation Rule works beautifully on the main form and subform once they
are dirty, it allows you to move to a new main form record without filling
out any of the subform fields (I guess because it only invokes the rule once
it sees the record as dirty?)  I tried editing one of the subform fields (a
date field which is automatically entered anyway) in the main form's On
Dirty and Before Update events, but it started processing the subform's
Validation Rules before all of the main form's field were filled in first
case and immediately gave a required field message when I move from form to
subform in the second case.  Have you run against this problem as well?

Any thoughts woud be very appreciated.  It is great to see so many ways of
tackling this issue.  I'm also checking out Dan's and A.D.'s suggestions.

Thank you,

Gale


On 5/29/07, Gale Perez <galeper at gmail.com> wrote:
>
> Dan, Steve, and A.D. (hope I didn't leave anyone out),
>
> Wow ... as always, I am amazed at how helpful this group is!!  Thank you
> all so much.  I'm very grateful for your thoughts and am looking at your
> suggestions right now.
>
> Gale
>
>
>  On 5/25/07, Dan Waters <dwaters at usinternet.com> wrote:
> >
> > 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
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > 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