On Error MsgBox Not Wanted

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Andy (pchelp_at_wtcinformme.com)
Date: 07/23/04


Date: Thu, 22 Jul 2004 23:35:45 -0400

Hi;

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

Not working.

Any Suggestions?

Andy



Relevant Pages

  • RE: Filter records based on user input
    ... Private Sub Text2_GotFocus ... I thought that the bookmark line would set the focus to the control in the ... which would filter your form based on the text in the textbox. ... It should filter the records as the user types the number. ...
    (microsoft.public.access.formscoding)
  • RE: Filter records based on user input
    ... Private Sub txtFilter_Change ... which would filter your form based on the text in the textbox. ... It should filter the records as the user types the number. ...
    (microsoft.public.access.formscoding)
  • RE: Filter records based on user input
    ... Private Sub txtFilter_Change ... which would filter your form based on the text in the textbox. ... It should filter the records as the user types the number. ...
    (microsoft.public.access.formscoding)
  • RE: Filter records based on user input
    ... Private Sub txtFilter_Change ... which would filter your form based on the text in the textbox. ... It should filter the records as the user types the number. ...
    (microsoft.public.access.formscoding)
  • Re: Keyword Search
    ... What I would suggest, however, is possibly an alternative way to the way you are doing, ie, a means by which your results are changed as the user types in a keyword. ... Say the first is UNBOUND and is called "txtSearchEnter" and is visible and indeed is the text box in which a user types in a keyword. ... In the on change event of txtSearchEnter, set up the following VBA - I am using a list box called "lstResults". ... Private Sub txtSearchEnter_Change ...
    (comp.databases.ms-access)