Re: Changing default key violation message?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jeff Boyce (JeffBoyce_IF_at_msn.com-DISCARD_HYPHEN_TO_END)
Date: 01/02/05


Date: Sun, 2 Jan 2005 11:40:12 -0800

Howard

What you've proposed requires Access to use a (somewhat) slower function
("DCount()"). But hey! whatever works! Have you tested your code?

-- 
Good luck
Jeff Boyce
<Access MVP>
"Howard" <nospam@home.please.co.uk> wrote in message
news:y6Sdna8hGvl4mUXcRVn-2g@nildram.net...
> Thank you Jeff,
>
> I presume I could check for the situation using something like the
following
>
>  If DCount("*","[Cars]","[CarReg]=" & Me!CarReg) >= 0 Then
>    MsgBox "This car already exists", vbOKOnly
>    Cancel = True
> end if
>
> Howard
>
> "Jeff Boyce" <JeffBoyce_IF@msn.com-DISCARD_HYPHEN_TO_END> wrote in message
> news:uasEv5M8EHA.2192@TK2MSFTNGP14.phx.gbl...
> > Howard
> >
> > You could add error handling to your code, intercept the error number,
and
> > create/display your own message.
> >
> > You could add code to the RegistrationNumber field's BeforeUpdate event
> > that
> > checks for the situation and prevents it, rather than allowing a user to
> > fill in a form and THEN telling him/her that they couldn't do that
("start
> > over, you made a mistake back up in line 7").  You'd add your message in
> > that BeforeUpdate routine, and set Cancel = True to not accept the
> > duplicated registration number.
> >
> > -- 
> > Good luck
> >
> > Jeff Boyce
> > <Access MVP>
> >
> > "Howard" <nospam@home.please.co.uk> wrote in message
> > news:g5qdnQT1mIvcWUrcRVn-2Q@nildram.net...
> >> Can this be done?
> >>
> >> How would I trap the error and present a more freindly message like
"You
> >> cannot have two cars with the same registration number" rather than the
> >> complex, non user freindly message that access gives me.
> >>
> >> Howard
> >>
> >>
> >>
> >
>
>


Relevant Pages

  • Re: Changing default key violation message?
    ... You could add code to the RegistrationNumber field's BeforeUpdate event that ... <Access MVP> ... "Howard" wrote in message ... non user freindly message that access gives me. ...
    (microsoft.public.access.formscoding)
  • Re: count with group by with OR
    ... Jeff Boyce <Access MVP>> With OR it is easy: ... Access can easily handle aggregate>> operations on a single column. ... >> Duane H. has an example of a survey/test database you could consider as a>> template if my suspicions are accurate -- see: ...
    (microsoft.public.access.queries)
  • Re: List Box bound column
    ... Not to sound like a broken record, but there are often many ways ... > From: Jeff Boyce ... > <Access MVP> ... >>> I want to change the listbox boundcolumn dynamicly by associating it ...
    (microsoft.public.access.forms)
  • Re: Whats fastest Unique Values or Group by?
    ... "Hallgeir" wrote in message ... >> Jeff Boyce ... >> <Access MVP> ... >>> I have a query with two output fields and a lot of records. ...
    (microsoft.public.access.queries)
  • Re: Form opens very slowly
    ... Jeff Boyce ... <Access MVP> ... > the basic problem with the structure of the DB itself. ... So the closer to Excell it is, ...
    (microsoft.public.access.forms)