[AccessD] A2K: Stop User from oving to new record

Heenan, Lambert Lambert.Heenan at AIG.com
Mon Apr 5 10:19:40 CDT 2004


"no joy" - what did not work? It's totally routine to do this kind of thing
in the BeforeUpdate event (but what you might have missed is that you also
need to do it in the BeforeInsert event too - that way you can validate NEW
records as well as existing ones that get edited.)

No need to mess with table validation rules and trapping the error. Just do
your own validation in the above two events.

BTW here's a way to check for nulls and empty string in one step, and it's a
tad easier to read (IMHO).

Instead of ...

If IsNull(Me.cmbOffence) Or Me.cmbOffence = "" Then

use...

If cmbOffence & "" = "" Then


> -----Original Message-----
> From:	Darren DICK [SMTP:d.dick at uws.edu.au]
> Sent:	Sunday, April 04, 2004 9:29 PM
> To:	Access Developers discussion and problem solving
> Subject:	Re: [AccessD] A2K: Stop User from oving to new record
> 
> Hi Bryan
> I did that no joy eg.
> 
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> 
> If IsNull(Me.cmbOffence) Or Me.cmbOffence = "" Then
>     MsgBox "Enter an offence"
>     Cancel = True
> End If
> 
> End Sub
> 
> What I need to do is somehow test if the user is on a new fresh record or
> has left th previous record with unfilled combos. Of
> course I can do it on the lost and got focus event.Thats fine whilst I am
> in the record
> EG record 5 has no offence recorded
> User goes to record 6 How do i alert the user that record 5 has a missing
> value then go back to that record?
> 
> 
> ----- Original Message ----- 
> From: "Bryan Carbonnell" <carbonnb at sympatico.ca>
> To: "Access Developers discussion and problemsolving"
> <accessd at databaseadvisors.com>
> Sent: Monday, April 05, 2004 10:25 AM
> Subject: Re: [AccessD] A2K: Stop User from oving to new record
> 
> 
> > On 5 Apr 2004 at 10:08, Darren DICK wrote:
> >
> > >  I have a simple subform with 4 fields on it
> > > ID (PK),  txtDateOfOccurence, cboClientName, cboOffence
> > >
> > > How can I tell if the user goes to a new record and they have not
> > > completed ALL fields in the previous record How do I alert them and
> > > then direct them back to the previous record?
> >
> > Use the before update event of the form. Check to make sure they
> > entered a vale and if not set Cancel = true in the event. That should
> > prevent the record from being saved and keep the sub form on the
> > "unfinished" record
> >
> > -- 
> > Bryan Carbonnell - carbonnb at sympatico.ca
> > The trouble with doing something right the first time is that nobody
> > appreciates how difficult it is.
> >
> >
> > -- 
> > _______________________________________________
> > 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