Re: On Error MsgBox Not Wanted
From: Andy (pchelp_at_wtcinformme.com)
Date: 07/27/04
- Next message: Chris: "Re: Subform update"
- Previous message: Sandra Daigle: "Re: Adding Images/Pics to forms"
- In reply to: Allen Browne: "Re: On Error MsgBox Not Wanted"
- Next in thread: Allen Browne: "Re: On Error MsgBox Not Wanted"
- Reply: Allen Browne: "Re: On Error MsgBox Not Wanted"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 27 Jul 2004 10:08:22 -0400
Allen;
Thank You for Your reply.
Will follow Your instructions an not use =CantBeBlank.
The thing I'm trying to overcome is the "Cryptic" message: "Index or Primary
key cannot contain a null value." and create a custom msgbox "...Hit the
escape key."
What I tried is:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 3314 Then
MsgBox "YES"
Else
MsgBox "NO"
End If
End Sub
To verify that 3314 is the error that generates the "Cryptic Message"
What returns is No.
Searched MSDN and it pointed to 8261. Tried that still No.
Help and search all Microst wasn't much help either.
Is it my code that is incorrect? Where do You find the actual error number
that generates "Index or Primary key cannot contain a null value."?
Andy
"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message
news:ezRmtsGcEHA.212@TK2MSFTNGP12.phx.gbl...
> 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
>
>
- Next message: Chris: "Re: Subform update"
- Previous message: Sandra Daigle: "Re: Adding Images/Pics to forms"
- In reply to: Allen Browne: "Re: On Error MsgBox Not Wanted"
- Next in thread: Allen Browne: "Re: On Error MsgBox Not Wanted"
- Reply: Allen Browne: "Re: On Error MsgBox Not Wanted"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|