Multi-field Index - Custom Error Message (1 Viewer)

Cosmos75

Registered User.
Local time
Today, 13:07
Joined
Apr 22, 2002
Messages
1,281
I have a table which has an index that is based on two fields (Multi-index - Unique). Is there a way I can create a custom error message when a user is trying to enter a new record that violates the multi-index??
 

doulostheou

Registered User.
Local time
Today, 13:07
Joined
Feb 8, 2002
Messages
314
Give an example of what would constitute a violation.
 

Cosmos75

Registered User.
Local time
Today, 13:07
Joined
Apr 22, 2002
Messages
1,281
I have a juntion table that stores the primary key from two other tables. Each primary key pair is unique and I have created an index in this juntion table that includes both primary keys and doesn't allow any duplicates. So when someone tries to enter a record for an existing primary key pair Access 2000 give a standard error message. Is there anyway I can create my own error message so that the user understands what he/she is doing wrong.

THANKS!
 

doulostheou

Registered User.
Local time
Today, 13:07
Joined
Feb 8, 2002
Messages
314
There are a few things you can do. The simplest would probably be to catch the error in an error handler. I believe you would place this in the before upadate event of the form:

Code:
On Error GoTo ErrHandle
'Additional Code can go here
GetOut:
Exit Sub
ErrHandle:
If Err.Number = [Color=Red]put error number here[/Color] Then
msgbox "This entry already exists."
Else
msgbox err.description
End If
 

Cosmos75

Registered User.
Local time
Today, 13:07
Joined
Apr 22, 2002
Messages
1,281
THANKS!

Where can I find out what the error number is?
 

doulostheou

Registered User.
Local time
Today, 13:07
Joined
Feb 8, 2002
Messages
314
Recreate the error and the access generated message should display t he error number.
 

Cosmos75

Registered User.
Local time
Today, 13:07
Joined
Apr 22, 2002
Messages
1,281
No Error Number for Index Violation

I get this error message.

"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."

Anyone one know the Err.Number for this?
 
R

Rich

Guest
Stop trying to jump the queue Fiz, that's only acceptable on the slopes in mainland Europe;)
 

Cosmos75

Registered User.
Local time
Today, 13:07
Joined
Apr 22, 2002
Messages
1,281
Thank you (Both of you!)

Rich and Fizzio, :)

Thanks!!

Is there somewhere on the internet I can find all or most of the error codes? Or do you guys just know them by heart?
 

Alexandre

Registered User.
Local time
Tomorrow, 01:07
Joined
Feb 22, 2001
Messages
794
I have a small DB that generates all VBA and Access error codes with there descriptions. Provide your email if interested.

As to your question, it is all in twisting Rich's ears. Right one provides MSDN articles IDs, left one VBA + Access error numbers. :p Don't dream too much about developping the same abilities. It is the product of many years of very intense training and the privilege of handful of bas-bleus.:D
 
Last edited:

Cosmos75

Registered User.
Local time
Today, 13:07
Joined
Apr 22, 2002
Messages
1,281
Alexandre,

Thanks!



(Ah, so that's the secret to Rich... Right Ear, Left Ear.):D

Well, as long as there are helpful people such as the people who replied to this thread, I won't fret over trying to develop Rich Ears.:p
 
Last edited:
R

Rich

Guest
Alex, I see the "Kilo" prefix is now applicable, will reminding you of this milestone have the same effect as reminding a female of her age when older than 25?:D
 
Last edited:

Users who are viewing this thread

Top Bottom