Access DLOOKUP with IF Function in MS ACCESS DB

Joined
May 18, 2017
Messages
2
Reaction score
0
Hello Guys,

Can you look into this code for me?
Not getting IF statement working!
..........................................................................................
Private Sub Machine_drawing_Number_AfterUpdate()
Dim MachNum As String
Dim Mat As String
Dim Tim As String
Dim stLinkCriteria2 As String
Dim Result As String


Mat = Me.Combo222.Value
Result = Me.Machine_drawing_Number.Value
stLinkCriteria2 = "[Combo222]= " & "'" & Mat & "'"


MachNum = DLookup("[Casting drawing Number]", "SlidingStem_Table", "[Machine_drawing_Number]= '" & Me.Machine_drawing_Number & "'")
Tim = DLookup("[Casting drawing Number]", "SlidingStem_Table", stLinkCriteria2)


If MachNum = Tim Then
MsgBox "This Machine Drawing Number : " & Result & " has already been entered in database with same Material" _
& vbCr & vbCr & "Please check the Machine number again.", vbInformation, "Duplicate information."
Me.Undo
Else
MsgBox "You can go ahead!"

End If

End Sub
 
Back
Top