Re: On Error MsgBox Not Wanted
From: Allen Browne (AllenBrowne_at_SeeSig.Invalid)
Date: 07/27/04
- Next message: Mark: "Re: Multiple select on forms"
- Previous message: Bonnie: "Error after blocking Dupe Record"
- In reply to: Andy: "Re: On Error MsgBox Not Wanted"
- Next in thread: Andy: "Re: On Error MsgBox Not Wanted"
- Reply: Andy: "Re: On Error MsgBox Not Wanted"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 27 Jul 2004 22:45:44 +0800
Select the line
If DataErr = 3314 Then
and press F9 to create a break point.
Cause the error. The code will stop there. When it does, open the Immediate
window (Ctrl+G), and enter:
? DataErr
That will tell you the number. Then press F8 or F5 to continue the code. You
can then remove the breakpoint (press F9 in the same line, or clear all
breakpoints through the menu)
-- 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:ee%23EaL%23cEHA.1764@TK2MSFTNGP10.phx.gbl... > 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. > > > > "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: Mark: "Re: Multiple select on forms"
- Previous message: Bonnie: "Error after blocking Dupe Record"
- In reply to: Andy: "Re: On Error MsgBox Not Wanted"
- Next in thread: Andy: "Re: On Error MsgBox Not Wanted"
- Reply: Andy: "Re: On Error MsgBox Not Wanted"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|