Selasa, 24 Desember 2013

Re: [MS_AccessPros] How to modify this code for numeric field

 

John,

I tried it before but got errors, Same now.
And what about quotes and SID after [ClientCIN]=
 stLinkCriteria = "[ClientCIN]=" & "'" & SID & "'"

What about quotes here:
'Check Clients table for duplicate ClientCIN
    If DCount("ClientCIN", "Clients", _
              stLinkCriteria) > 0 Then
 'Undo duplicate entry
        Me.Undo

Khalid


On Tuesday, December 24, 2013 6:19 PM, John Viescas <JohnV@msn.com> wrote:
 
Kahlid-

I would guess that all you need to do is remove the quotes around this:

   stLinkCriteria = "[ClientCIN]=" & SID


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 Dec 24, 2013, at 11:42 AM, Khalid Tanweer <khalidtanweerburrah@yahoo.com> wrote:

Hi All,
Could somebody help me to modify the following code for a numeric field, the current code is for a text field.

Private Sub ClientCIN_BeforeUpdate(Cancel As Integer)
    
    CmdUndoAddRcrdClient.Enabled = False
    CmdCloseAddRcrdClient.Enabled = True
    CmdAddRcrdClient.Enabled = True
    
    Dim SID As String
    Dim stLinkCriteria As String
    Dim rsc As DAO.Recordset

    Set rsc = Me.RecordsetClone

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

    'Check Clients table for duplicate ClientCIN
    If DCount("ClientCIN", "Clients", _
              stLinkCriteria) > 0 Then
        'Undo duplicate entry
        Me.Undo
        'Message box warning of duplication
        MsgBox "Client CIN: '" & SID & "' has already been allotted." & vbCrLf & _
              "You will now been taken to the record of Client CIN. '" _
              & SID & "'.", vbExclamation _
        , "PCTL Accounts - Duplicate Entry"
        'Go to record of original ClientCIN
        rsc.FindFirst stLinkCriteria
        Me.Bookmark = rsc.Bookmark
    End If
    Set rsc = Nothing
End Sub

Khalid
Kh



__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar