user friendly message (1 Viewer)

Spira

Registered User.
Local time
Today, 08:01
Joined
Feb 23, 2004
Messages
35
does anyone know how to customise the

"the changes you requested to the table were not successful because they would create duplicate values in the index, primary key or relationship"

message box so that you can put your own message there ???

thanks for your help :D
 

Spira

Registered User.
Local time
Today, 08:01
Joined
Feb 23, 2004
Messages
35
a.sinatra said:
Is it on a button click that you want the error?

no, on the input of a new record. if the record key is duplicated i wish to make my own message box to appear rather than the access one, thanks
 

WayneRyan

AWF VIP
Local time
Today, 08:01
Joined
Nov 19, 2002
Messages
7,122
spira,

You can use the form's BeforeInsert event.

Don't know your names, but this is the general idea.

Code:
If DCount("[SomeField]", "YourTable", "[YourKey] = " & Me.YourKey) > 0 Then
   MsgBox("Whatever ...") <-- Or bring up your own form
   Me.Cancel = True
End If

Wayne
 

R6Flyer

Yamaha hooligan
Local time
Today, 08:01
Joined
Nov 21, 2003
Messages
95
Spira said:
no, on the input of a new record. if the record key is duplicated i wish to make my own message box to appear rather than the access one, thanks

Try putting the following code on the form error event:

Code:
If DataErr = 3022 Then
    MsgBox "Your custom message appears here.", vbInformation
    Response = acDataErrContinue
    Me.Undo
End If

This should display your custom message and undo the duplicated data entry as opposed to the rather ugly access standard message.
 

Spira

Registered User.
Local time
Today, 08:01
Joined
Feb 23, 2004
Messages
35
R6Flyer said:
Try putting the following code on the form error event:

Code:
If DataErr = 3022 Then
    MsgBox "Your custom message appears here.", vbInformation
    Response = acDataErrContinue
    Me.Undo
End If

This should display your custom message and undo the duplicated data entry as opposed to the rather ugly access standard message.

Thanks very much for your help, problem solved!!!!! :D
 

Users who are viewing this thread

Top Bottom