[AccessD] Set Focus On Control When Validation Fails

Rocky Smolin - Beach Access Software bchacc at san.rr.com
Tue Mar 11 00:20:00 CST 2003


Bert-Jan:

I always found my syntax to be a bit more self-documenting.  But I suppose
it's what you're used to.  Yours is more compact and elegant, but mine reads
more like a regular sentence.  I'll bet the object code is the same, though.

Rocky

----- Original Message -----
From: "Bert-Jan Brinkhuis" <thevigil at kabelfoon.nl>
To: <accessd at databaseadvisors.com>
Sent: Monday, March 10, 2003 12:48 PM
Subject: Re: [AccessD] Set Focus On Control When Validation Fails


> Rocky,
>
> I renewed my subscription to this list recently. And found it to be very
> helpful already. Didn't have anything to ask the list, yet ;-), but got
some
> realy helpful info about some things i was about to ask the list......
> Hope i will be able to help soon.....
>
> I was wondering though, Rocky, why you don't use something like:
>
>  Private Sub txtBarCodePrefix_BeforeUpdate(Cancel As Integer)
>      Cancel = NOT ValidationTests
>  End Sub
>
> This is how i am writing it. Is there any special reason for your syntax?
Or
> any special reason i should NOT use my syntax?
>
> Bert-Jan Brinkhuis
>
>
> ----- Original Message -----
> From: "Rocky Smolin - Beach Access Software" <bchacc at san.rr.com>
> To: <accessd at databaseadvisors.com>
> Sent: Monday, March 10, 2003 5:15 PM
> Subject: Re: [AccessD] Set Focus On Control When Validation Fails
>
>
> > John:
> >
> > My result is weirder than yours.  I have seven fields I put the
validation
> > code into the BeforeUpdate event (no need for .SetFocus, because the
focus
> > *in theory* never goes away from the control).
> >
> > I have a bunch of validation tests in a function:
> >
> > Private Sub txtBarCodePrefix_BeforeUpdate(Cancel As Integer)
> >     If ValidationTests = False Then Cancel = True
> > End Sub
> >
> > Works on three, fails on four.  And I can't see ANY differences between
> the
> > three that work and the four that don't.  Could it be timing problem in
> the
> > event sequence?  Maybe I'll try putting a delay loop in the BeforeUpdate
> > event, see if that changes anything.
> >
> > Rocky Smolin
> > Beach Access Software
> >
> > ----- Original Message -----
> > From: "John Clark" <John.Clark at niagaracounty.com>
> > To: <accessd at databaseadvisors.com>
> > Sent: Monday, March 10, 2003 7:19 AM
> > Subject: Re: [AccessD] Set Focus On Control When Validation Fails
> >
> >
> > > How weird...I am working on the exact same problem. I noticed that a
> > > program that I am about to roll out accepts any date, in the many date
> > > fields. Some of the dates need to be later than others that are there
> > > (for instance, there is a "Sent to Sheriff" field, and a "Returned
from
> > > Sheriff" field, and you cannot receive it before it is sent).
> > >
> > > I used the code:
> > >
> > > If datFromSheriff.Value < datToSheriff.Value Then
> > >     MsgBox "This date cannot be previous to the Sent to Sheriff Date",
> > > vbOKOnly, "Date Error"
> > >     datFromSheriff = ""
> > >     datFromSheriff.SetFocus
> > > End If
> > >
> > > And I have tried it in the "On Lost Focus", "On Change" (stupid),
> > > "Before Update" (there now), and "After Update" events, but none
worked.
> > > It actually worked with "Lost Focus" but the SetFocus did not...it
went
> > > to the next field in the tab order.
> > >
> > > Did you get this working?
> > >
> > > John Clark
> > >
> > >
> > > >>> bchacc at san.rr.com 03/09/03 01:45PM >>>
> > > Dear List
> > >
> > > I have a couple of simple validation tests:
> > >
> > >     If Not IsNumeric(Nz(txtStartingRoomNumber)) Then
> > >         MsgBox "Starting Room Number Must Be Numeric.", vbExclamation
> > >         txtStartingRoomNumber.SetFocus
> > >         Exit Sub
> > >     End If
> > >
> > >     If Val(Nz(txtStartingRoomNumber)) > 9999999 Then
> > >         MsgBox "Starting Room Number Must Be Less Than 7 Digits.",
> > > vbExclamation
> > >         txtStartingRoomNumber.SetFocus
> > >         Exit Sub
> > >     End If
> > >
> > > in the AfterUpdate event of txtStartingRoomNumber.  But the SetFocus
> > > does not work.  The focus ends up being set on the next control in the
> > > tab sequence.  I tried the tests in the Lost Focus event with the same
> > > result.
> > >
> > > I know there must be a simple way to return the focus to the control
> > > but I can't see it. (Maybe I shouldn't work on Sunday but the kids are
> > > in Sunday school and it's quiet.) :)
> > >
> > > MTIA,
> > >
> > > Rocky Smolin
> > > Beach Access Software
> > > _______________________________________________
> > > 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