Duplicate Record

music_al

Registered User.
Local time
Today, 14:52
Joined
Nov 23, 2007
Messages
200
In a table I have 2 fields for the Primary Key (Patient_No and Date). I have created a form for this table and I want to check that the same patient does not have 2 appointments set on the same date - hence the 2 primary keys.

I have managed to capture the Error that is generated when a duplicate record is about to be created. The problem is, Access only detects this when I click Next Record. I have tried using...

Private Sub Date_Change()
DoCmd.GoToRecord , , acNext 'jumps to next record to check if duplicate
DoCmd.GoToRecord , , acPrevious 'jumps back if not duplicate

End Sub

That works nicely when a duplicate date in NOT entered, but when a duplicate date IS entered it just returns an error message saying...

Run-time Error '2105'

You can't go to the specified record.


Does anyone know a solution to this ?

Thank you


Al
 

Users who are viewing this thread

Back
Top Bottom