Senin, 20 Januari 2020

Re: [MSAccessProfessionals] Duplication of entry is not checked

Khalid,
Is there still an issue? Your reply just provides code with out any status regarding your question. Also, you haven't included any part of the previous thread in your reply. It always helps to include previous messages.

If it doesn't work, I would add this line

  stLinkCriteria = "[TripNo]=" & SID
  debug.Print stLinkCriteria      'open the debug window to view this

Regards,
Duane
 



From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> on behalf of Khalid Tanweer via Groups.Io <khalidtanweerburrah=yahoo.com@groups.io>
Sent: Monday, January 20, 2020 6:01 AM
To: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io>
Subject: Re: [MSAccessProfessionals] Duplication of entry is not checked
 
Hi all,
Sorry for botheration, the code is now as:

Private Sub TripNo_BeforeUpdate(Cancel As Integer)
 Dim SID As Long
    Dim stLinkCriteria As String
    Dim rsc As DAO.Recordset
 
    Set rsc = Me.RecordsetClone
 
    SID = Me.TripNo.Value
       
    stLinkCriteria = "[TripNo]=" & SID
 
    'Check Add New Cst table for duplicate TripNo
    If DCount(TripNo, "CST", _
              stLinkCriteria) > 0 Then
        'Undo duplicate entry
        Me.Undo
        'Message box warning of duplication
        MsgBox "TripNo: '" & SID & "' has already been allotted." & vbCrLf & _
              "You will now been taken to the record of TripNo. '" _
              & SID & "'.", vbExclamation _
        , "PTF Guide - Duplicate Entry"
        'Go to record of original TripNo
        rsc.FindFirst stLinkCriteria
        Me.Bookmark = rsc.Bookmark
    End If
    Set rsc = Nothing
End Sub

Thanks for replies,
Khalid

Tidak ada komentar:

Posting Komentar