Hi everybody,i would be grateful if someone could help me on this:
I have the following code to prevent duplicate records
Private Sub ypothesi_id_AfterUpdate()
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.ypothesi_id.Value
stLinkCriteria = "[ypothesi_id]=" & "'" & SID & "'"
'Check StudentDetails table for duplicate StudentNumber
If DCount("ypothesi_id", "status_energeiwn", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Student Number " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original Student Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
The code above works for the form itself,but i use this form as a subform in another form called Client_form.So when i am in the Client_form this code doesnt work ,probably because of the wrong references i use inside the vba code,right?
Can anyone help me with the correct references because i am so confused with these references.Should all the "Me" references change?
Thank you in advance!
I have the following code to prevent duplicate records
Private Sub ypothesi_id_AfterUpdate()
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.ypothesi_id.Value
stLinkCriteria = "[ypothesi_id]=" & "'" & SID & "'"
'Check StudentDetails table for duplicate StudentNumber
If DCount("ypothesi_id", "status_energeiwn", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Student Number " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original Student Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
The code above works for the form itself,but i use this form as a subform in another form called Client_form.So when i am in the Client_form this code doesnt work ,probably because of the wrong references i use inside the vba code,right?
Can anyone help me with the correct references because i am so confused with these references.Should all the "Me" references change?
Thank you in advance!