Sabtu, 28 Juni 2014

Re: [MS_AccessPros] Check duplicate record

 

Khalid-


Looks like you're missing a quote for the CstName predicate:

    stLinkCriteria = "[MembershipType]='" & [cboMembershipType] & "' and [MemberID]=" & cboMemberID & _
    " and [CstName]='" & [cboCstName] & ""

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Jun 28, 2014, at 4:13 AM, Khalid Tanweer khalidtanweerburrah@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Hi All,
I am honored to say that i have learnt a lot from this group with the utmost support and guidance of all seniors and MVP's. That is why i am able to make new databases.

Now i am stuck in an event and need help, error message says:
Run-time error '3075'
Syntax error (missing operator) in query expression....

Private Sub cboMemberID_BeforeUpdate(Cancel As Integer)
    Dim SID As String
    Dim stLinkCriteria As String
    Dim rsc As DAO.Recordset
   
    stLinkCriteria = "[MembershipType]='" & [cboMembershipType] & "' and [MemberID]=" & cboMemberID & _
    " and [CstName]=" & [cboCstName] & ""
           

   'Check CST Transaction table for duplicate MemberID for selected CstName
    If DCount("*", "CST Transaction", stLinkCriteria) > 0 Then
        'Message box warning of duplication
        MsgBox "This Member ID: " & [MemberID] & " has already been allotted" & vbCrLf & _
        "For Membership type: " & [cboMembershipType] & vbCrLf & _
        "And CST Name: " & [cboCstName] & vbCrLf & _
        "" & vbCrLf & _
        "You will now been taken to the record of Member ID '" & [MemberID] & "'" _
        , vbInformation, "SCP Guide - Duplicate Entry"

        'Undo duplicate entry
        Me.Undo
        CmdUndoAddRcrdEmp.Enabled = False
                
        'Go to record of original MemberID for selected CstName
        Set rsc = Me.RecordsetClone
        rsc.FindFirst stLinkCriteria
        Me.Bookmark = rsc.Bookmark
    End If
    Set rsc = Nothing
End Sub

Regards,
Khalid



__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar