Merge two codes together?

R

Randy

I have two codes that work fine individually but I need them to be combined
in the before update event. The way I have it now is the part that checks
for duplicate numbers wroks fine but the part of the code that asks "Changes
have been made...." occurs even if a change has not been made or if it is a
new record. What do I need to do here...Thanks...Randy

Private Sub CertID_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
If Not Me.NewRecord Then
If MsgBox("Changes have been made to the Applicant ID" _
& vbCrLf & "Do you want to make these changes?" _
, vbYesNo, "Changes Made...") = vbNo Then
Cancel = True
Me.CertID.Undo
End If

SID = Me.Cert_ID.Value
stLinkCriteria = "[Cert_ID]=" & "'" & SID & "'"

'Check Account table for duplicate certificate numbers
If DCount("Cert_ID", "Account", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "WARNING! Duplicate Certificate. Certificate " _
& SID & " has already been entered." _

'Go to record of original Certificate Number

End If
End If

Set rsc = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top