Help with different Dlookup with 3 criteria (1 Viewer)

lookforsmt

Registered User.
Local time
Today, 20:56
Joined
Dec 26, 2011
Messages
592
i am sure the solution is in front of me, but as i told you i have limited vba knowledge. I am confused at the moment and with the last code that you provided.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:56
Joined
Sep 21, 2011
Messages
5,960
OK,
This is what I tested out in the IW, which is what I do when I have your problem.

Code:
tt="0001298020207250293177718"
dt=#20/10/2019#
strcriteria = "MICR_ndt = '" &tt & "' AND PDC_dueDate = #" & dt & "#"
? strcriteria
MICR_ndt = '0001298020207250293177718' AND PDC_dueDate = #20/10/2019#
? DCount("1", "tbl_Master", strcriteria)
1
 

lookforsmt

Registered User.
Local time
Today, 20:56
Joined
Dec 26, 2011
Messages
592
Thanks Gasman for the patient and explaining me this. Putting the punctuation in the right place is very important.

i have the below working code.
Code:
Private Sub MICR_Scan_BeforeUpdate(Cancel As Integer)
    Dim strMIRC As String
[COLOR="Blue"]    Dim strDate As Date
    Dim strCriteria As String[/COLOR]
    
    intRemarks = 0
    
    strMIRC = Trim(ReplaceChars(Me.MICR_Scan) & "")
[COLOR="blue"]    strDate = Me.Parent!PDCDueDate
    strCriteria = "MICR_ndt = '" & strMIRC & "' And PDC_dueDate = #" & strDate & "#"[/COLOR]
    
[COLOR="Red"]'    TableField = variable And NextTableField = variable1 And lastTableField = variable2[/COLOR]
    
    If Len(strMIRC) < 1 Then
        MsgBox "Need to enter Cheque MIRC", vbExclamation + vbOKOnly
        Exit Sub
    End If
    
    If DCount("1", "tbl_temp_Validate", "MICR = '" & strMIRC & "'") > 0 Then
        Me.Undo
        'Cancel = True

        'Message box warning of duplication
        MsgBox "Duplicate Cheque MICR and CreditAC already Scanned " & "" _
            & vbCr & Me.MICR_Scan, vbInformation _
            , " Duplicate MICR"
        Exit Sub
    End If
[COLOR="Red"]'----------------------------------------------------------------------------------
'    If DCount("1", "tbl_Master", "MICR_ndt = '" & strMIRC & "'") < 1 Then
'----------------------------------------------------------------------------------[/COLOR]

 [COLOR="Blue"]      If DCount("1", "tbl_Master", strCriteria) < 1 Then[/COLOR]

Debug.Print strCriteria
'Debug.Print strDate
        
        Me.Status.Value = "UnMatch"
        Me.cboRemark = DLookup("RejectReason", "tbl_RejectReason", "SrNos = 5")
        intRemarks = intRemarks + 1
        'Cancel = True
        'Undo duplicate entry
        '         Me.Undo
        MsgBox "Incorrect MICR Scanned " & "" _
            & vbCr & Me.MICR_Scan & " " _
            & vbCr & "Kindly check and correct Scanned MICR.", vbInformation _
            , " MICR Information"
    End If
End Sub
Thank you once again
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:56
Joined
Sep 21, 2011
Messages
5,960
Well I made you work for it I admit :), but you should get some satisfaction for getting part way there.

Sadly, there is no alternative to learning. You should have learnt a few debugging techniques, if nothing else?

Google has always helped me. That is my first place of call, pretty much for anything these days.

What we did before it, I cannot remember. :D
 

lookforsmt

Registered User.
Local time
Today, 20:56
Joined
Dec 26, 2011
Messages
592
Rightly, there is no alternate for learning. I have tried to learn this but its difficult to understand from the middle, i need to understand from the beginning like kindergarten.

Yes, before posting any thread i look for Google, everywhere for an answer and some of you guys are amazing who not only provide help but also guide to the right path.
keep it up and God bless you.
Thanks
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom