Revision: 9681
Updated Code
at April 28, 2010 20:18 by heislekw
Updated Code
Private Sub SubjectID_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Handler
Dim SubID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SubID = Me.SubjectID.Value
stLinkCriteria = "[SubjectID]=" & SubID
'Check table for duplicate
If DCount("SubjectID", "tblSubjects", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "The Subject ID " & SubID & " is already in use." & _
Chr(13) & Chr(13) & "Please check to see if this patient has already been entered. " & _
"If not, then assign the patient a Subject ID.", vbInformation, "Duplicate Subject ID"
'Go to the duplicate record
'rsc.FindFirst stLinkCriteria
'Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
Exit_Handler:
Exit Sub
Err_Handler:
If Err.Number = 94 Then
' Invalid use of Null error
Resume Exit_Handler
Else
End If
End Sub
Revision: 9680
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 17, 2008 16:02 by heislekw
Initial Code
Private Sub SubjectID_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Handler
Dim SubID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SubID = Me.SubjectID.Value
stLinkCriteria = "[SubjectID]=" & SubIB
'Check table for duplicate
If DCount("SubjectID", "tblSubjects", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "The Subject ID " & SubID & " is already in use." & _
Chr(13) & Chr(13) & "Please check to see if this patient has already been entered. " & _
"If not, then assign the patient a different number.", vbInformation, "Duplicate Last Name"
'Go to the duplicate record
'rsc.FindFirst stLinkCriteria
'Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
Exit_Handler:
Exit Sub
Err_Handler:
If Err.Number = 94 Then
' Invalid use of Null error
Resume Exit_Handler
Else
End If
End Sub
Initial URL
Initial Description
Initial Title
Check for duplicate value (numeric)
Initial Tags
Initial Language
Visual Basic