R
Rillo
I have a table in which there are records containing serial numbers and other
data describing items in the record.
The serial number is supposed to be unique to each record and is the record
key.
When I try to enter a record with a duplicate serial number, Access displays
two messages when I leave my data entry form.
The messages are
“The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship"
(which is apparently Error 3022).
and a message to the effect that I cannot save the record at this time.
This is exactly what I want to happen , however
a. could you please advise me on how I can create some code that would
inform the user in a user-friendly message that he/she is attempting to
allocate a serial number that has already been used ?
b. to which event the code should be attached?
c. do I need to use VB or can I create a macro to achieve this?
I tried the following code in various events linked to the serial number
field, but this did not work. However, I am not very good at creating VBcode!!
If (Me.RecordsetClone.RecordCount) > 0 Then
MsgBox "This serial number has been used previously", , "TEST"
Cancel = True
End If
End Sub
I am using Access 2002 with Access 2000 file formats
data describing items in the record.
The serial number is supposed to be unique to each record and is the record
key.
When I try to enter a record with a duplicate serial number, Access displays
two messages when I leave my data entry form.
The messages are
“The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship"
(which is apparently Error 3022).
and a message to the effect that I cannot save the record at this time.
This is exactly what I want to happen , however
a. could you please advise me on how I can create some code that would
inform the user in a user-friendly message that he/she is attempting to
allocate a serial number that has already been used ?
b. to which event the code should be attached?
c. do I need to use VB or can I create a macro to achieve this?
I tried the following code in various events linked to the serial number
field, but this did not work. However, I am not very good at creating VBcode!!
If (Me.RecordsetClone.RecordCount) > 0 Then
MsgBox "This serial number has been used previously", , "TEST"
Cancel = True
End If
End Sub
I am using Access 2002 with Access 2000 file formats