Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Custom Error Messages

ImperiaGirlImperiaGirl Member Posts: 1
Here's my problem (keep in mind that I'm not exactly an Access pro which is evident by the problem I have).

I have a primary key set in my table but HATE that tacky error message that Access pops up when someone tries to enter duplicate information. I know a validation rule & text would help, however I don't know the code that won't allow duplicates to be entered. Since Access pretty much takes care of that part for me - I really just need to know how to customize the error msg that comes up when a duplicate value is inserted.

Many thanks in advance for any assistance!

Comments

  • compuchipcompuchip Member Posts: 273
    Use the OnError event of your form. If you let Access create the function for you, you will end up with
    [code]
    Private Sub Form_Error(DataErr As Integer, Response As Integer)

    End Sub
    [/code]

    You only have to fill it in, it even gives you the error number.
    If you don't know it, use this:
    [code]
    Private Sub Form_Error(DataErr As Integer, Response As Integer)
    MsgBox "The error was " & DataErr
    End Sub
    [/code]
    and try to enter a duplicate value.

    PS) About Response, the help file says the following:
    Set it to...
    acDataErrContinue = Ignore the error and continue without displaying MS Access' default error message. You can display a custom error message instead of the default error message.

    acDataErrDisplay (default setting) = Display the default MS Access error message.

    I think you should be able to figure out the rest (if any) for yourself :))

    : Here's my problem (keep in mind that I'm not exactly an Access pro which is evident by the problem I have).
    :
    : I have a primary key set in my table but HATE that tacky error message that Access pops up when someone tries to enter duplicate information. I know a validation rule & text would help, however I don't know the code that won't allow duplicates to be entered. Since Access pretty much takes care of that part for me - I really just need to know how to customize the error msg that comes up when a duplicate value is inserted.
    :
    : Many thanks in advance for any assistance!
    :

  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    ____ { http://forcoder.org } free ebooks and video tutorials about [ Swift PHP Java MATLAB R Python Objective-C Ruby Delphi Assembly C# JavaScript C++ C Visual Basic Go Visual Basic .NET Perl Scratch PL/SQL Transact-SQL Apex VBScript Crystal Erlang Lua Fortran ABAP Scala Awk ML Scheme Julia LabVIEW F# Kotlin Ada Hack COBOL FoxPro Dart SAS D Bash Lisp Alice Rust Prolog Clojure Logo ]

Sign In or Register to comment.