Minggu, 19 Januari 2020

[MSAccessProfessionals] Duplication of entry is not checked

Hi all,
I'm working on a form "Add New Cst". On its field Name "TripNo" and Control source is "TripNo" Format Standard, decimal places = 0
On its BeforeUpdateEvent I'm getting a Run time error '3075;
Syntax error (missing operator) in query expression 'TripNo= &
[TripNo]';
I want this message not comes and it should check for Duplicate entry, Event is:

Private Sub TripNo_BeforeUpdate(Cancel As Integer)
     Dim stLinkCriteria As String
     Dim rsc As DAO.Recordset
   'Don 't check if not on a new row
   'If Not Me.NewRecord Then Exit Sub
    stLinkCriteria = "TripNo= & [TripNo] " '"
                     Debug.Print stLinkCriteria
    
   'Check Cst table for duplicate TripNo
    If DCount("*", TripNo, stLinkCriteria) > 0 Then
 
        'Message box warning of duplication
            MsgBox "This Trip No: " & [TripNo] & " has already been entered" & vbCrLf & _
               "at" & [TripNo] & "." _
               , vbInformation, "Duplicate Entry"
 
            'Undo duplicate entry
            Me.Undo
               
            'Go to record of original TripNo
            Set rsc = Me.RecordsetClone
            rsc.FindFirst stLinkCriteria
            Me.Bookmark = rsc.Bookmark
            Set rsc = Nothing
    End If
End Sub
-----------
Please help where is the mistake.
Thanks Khalid
_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#115408) | Reply To Group | Reply To Sender | Mute This Topic | New Topic

Your Subscription | Contact Group Owner | Unsubscribe [sugeng.panjalu.access@blogger.com]

_._,_._,_

Tidak ada komentar:

Posting Komentar