R
Randy
I copied this code off the internet and revised it slightly to work with
preventing duplicate certificate nubers via form. Works great. I'm trying
to revise it again to work on my employee time sheet database. I need it to
prevent duplicate dates for the same employee. I need some way to add [EID]
(employee ID) to the code so that only one employee per date can be entered
in the database. Somthing like: [Current_Date] & [EID] Thanks...Randy
Private Sub CurrentDate_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.CurrentDate.Value
stLinkCriteria = "[Current_Date]=" & "'" & SID & "'"
'Check IDRa table for duplicate date for same employee
If DCount("Current_Date", "IDRa", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "WARNING! Duplicate Entry. This Employee " _
& SID & " has already been entered for this date." _
'Go to record of original employee date worked
End If
Set rsc = Nothing
End Sub
preventing duplicate certificate nubers via form. Works great. I'm trying
to revise it again to work on my employee time sheet database. I need it to
prevent duplicate dates for the same employee. I need some way to add [EID]
(employee ID) to the code so that only one employee per date can be entered
in the database. Somthing like: [Current_Date] & [EID] Thanks...Randy
Private Sub CurrentDate_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.CurrentDate.Value
stLinkCriteria = "[Current_Date]=" & "'" & SID & "'"
'Check IDRa table for duplicate date for same employee
If DCount("Current_Date", "IDRa", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "WARNING! Duplicate Entry. This Employee " _
& SID & " has already been entered for this date." _
'Go to record of original employee date worked
End If
Set rsc = Nothing
End Sub