Re: On Error MsgBox Not Wanted

From: Allen Browne (AllenBrowne_at_SeeSig.Invalid)
Date: 07/23/04


Date: Fri, 23 Jul 2004 12:11:44 +0800

Teach the user to press Esc key to undo the entry if they want out.

If you use Form_Error, it should be limited ot DataErr 3314. Form_Error
could fire for other reasons also, e.g. related record required (3201),
invalid type (2113), duplicate index (3022), or even a network problem if
the data is on a server (3024). You cannot do that if you set the form's
OnError property to =CantBeBlank, because you can only pass the DataErr
value from inside the Form_Error procedure.

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Andy" <pchelp@wtcinformme.com> wrote in message
news:e8ikTXGcEHA.3716@TK2MSFTNGP11.phx.gbl...
>
> When a user types in a required field, and then deletes the characters,
and
> tries to move to a different record the user gets the internal warning
box:
> "Index or Primary key cannot be blank".
>
> Created a simple procedure that works:
> Private Sub Form_Error(DataErr As Integer, Response As Integer)
> Response = acDataErrContinue
> DoCmd.DoMenuItem acFormBar, acEdit, acUndo
> End Sub
>
> Realized that this is helpful for many Forms.
>
> Want to create one Function instead of multiple Private Subs.
>
> Public Function CantBeBlank()
>     Dim DataErr As Integer
>     Dim Response As Integer
>
>     Response = acDataErrContinue
>     DoCmd.DoMenuItem acFormBar, acEdit, acUndo
>
> End Function
>
> It called correctly =CantBeBlank()
> But the internal warning box appears.
>
> Added:   DoCmd.SetWarnings False


Relevant Pages

  • Re: Using Form_Error to trap Data Errors
    ... I'm not sure there is a list of the DataErr values. ... The Response argument is provided so you can set it to tell Access how to ... > reason. ... > Private Sub Form_Error ...
    (microsoft.public.access.formscoding)
  • Re: Simple error message for duplicate records
    ... That DataErr code is just what I was looking for. ... Private Sub Form_Error(DataErr As Integer, Response As Integer) ...
    (microsoft.public.access.forms)
  • Re: On Error MsgBox Not Wanted
    ... If DataErr = 3314 Then ... >> OnError property to =CantBeBlank, because you can only pass the DataErr ... >>> Private Sub Form_Error(DataErr As Integer, Response As Integer) ...
    (microsoft.public.access.forms)
  • Re: Substituting a more user friendly error message
    ... You can do this in the On Error event of the FORM. ... Private Sub Form_Error(DataErr As Integer, Response As Integer) ... If DataErr = 2279 Then '**not formatted for input mask** ...
    (microsoft.public.access.forms)
  • Re: Substituting a more user friendly error message
    ... You can do this in the On Error event of the FORM. ... Private Sub Form_Error(DataErr As Integer, Response As Integer) ... If DataErr = 2279 Then '**not formatted for input mask** ...
    (microsoft.public.access.formscoding)