Custom Error Messages

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

  • 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!
    :

Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion