Turn Off Default Validation Error Messages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ryan.paquette@gmail.com

    Turn Off Default Validation Error Messages

    Hello'

    I have a field in which I require validation in a before update
    event.
    The validation code I have works fine, no problem there.

    However I would like to turn off the default validation error
    message...as it shows up in addition to the message I am providing.

    For some reason, (SetWarnings = False) does not apply to this error...
    Error: "The value in the field or record violates the validation rule
    for the record or field..."

    Here is my code;

    Private Sub txtSample_Befor eUpdate(Cancel As Integer)
    SetWarnings = False

    Me.txtSample.Ba ckColor = 16777215

    Dim varReturnValue As Variant

    varReturnValue = DLookup(Me!txtS ample, "tblResults ", "[Sample] =
    " & Chr$(34) & Me! txtSample & Chr$(34))

    If Not IsNull(varRetur nValue) Then

    MsgBox "This Sample # is already allocated, please input a
    different sample number. If you would like to edit the entered sample
    #, please use the data review prompts from the main menu."

    Cancel = True
    End If
    End Sub

    I assumed that SetWarnings would remove this message but it does not.
    Is there another Default messages function I am unaware of?

    Thanks












  • Tom van Stiphout

    #2
    Re: Turn Off Default Validation Error Messages

    On Fri, 17 Oct 2008 10:27:41 -0700 (PDT), "ryan.paquette@ gmail.com"
    <Ryan.Paquette@ gmail.comwrote:

    Read the default message carefully. It suggests there is a validation
    rule, either at the table level or at the field level. Design the
    underlying table and check it out.

    -Tom.
    Microsoft Access MVP

    >Hello'
    >
    >I have a field in which I require validation in a before update
    >event.
    >The validation code I have works fine, no problem there.
    >
    >However I would like to turn off the default validation error
    >message...as it shows up in addition to the message I am providing.
    >
    >For some reason, (SetWarnings = False) does not apply to this error...
    >Error: "The value in the field or record violates the validation rule
    >for the record or field..."
    >
    >Here is my code;
    >
    >Private Sub txtSample_Befor eUpdate(Cancel As Integer)
    >SetWarnings = False
    >
    >Me.txtSample.B ackColor = 16777215
    >
    Dim varReturnValue As Variant
    >
    varReturnValue = DLookup(Me!txtS ample, "tblResults ", "[Sample] =
    >" & Chr$(34) & Me! txtSample & Chr$(34))
    >
    If Not IsNull(varRetur nValue) Then
    >
    MsgBox "This Sample # is already allocated, please input a
    >different sample number. If you would like to edit the entered sample
    >#, please use the data review prompts from the main menu."
    >
    Cancel = True
    End If
    >End Sub
    >
    >I assumed that SetWarnings would remove this message but it does not.
    >Is there another Default messages function I am unaware of?
    >
    >Thanks
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >

    Comment

    • Tony Toews [MVP]

      #3
      Re: Turn Off Default Validation Error Messages

      "ryan.paquette@ gmail.com" <Ryan.Paquette@ gmail.comwrote:
      >However I would like to turn off the default validation error
      >message...as it shows up in addition to the message I am providing.
      >
      >For some reason, (SetWarnings = False) does not apply to this error...
      >Error: "The value in the field or record violates the validation rule
      >for the record or field..."
      That's not a warning message. That's an error message. It is also happening
      outside your code and is happening when Access is attempting to save the record.

      Tony
      --
      Tony Toews, Microsoft Access MVP
      Please respond only in the newsgroups so that others can
      read the entire thread of messages.
      Microsoft Access Links, Hints, Tips & Accounting Systems at

      Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

      Comment

      Working...