Data Validation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to do some data validation on a form but am having extreame
problems. I have a data entry form which is used to strictly add records,
when the user inputs the data and hits the save button I want to check and
see if the primary key(DrawingNum) already exists in the table or not. If it
does I want to display a msgbox. I have tried numerious things to try and
get this to work, some things I have tried have been DLookup and DCount both
in the Save button Event Procedure and the Before Update Event Procedure.
Niether of these methods have worked and I have set them up exactly as shown
by help files and from your responses on this. As of right now when you
click the save button and if the DrawingNum is already in the table Access
will genterate its own error telling you that there is a duplicate primary
key........ so there must be a proper way to check this. I don't want to use
Microsofts Access error description because it is not detailed enough for a
general user that is why I would like to check and put in my own message.
Any further help would be great on this matter. Thanks.
 
This was my solution...
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 3022 Then
Response = 0: a = MsgBox("This record has a duplicate Id.", , "Message")
End If ....

Hope this helps.
 
Back
Top