Access Access DLookup Function – more than 1 criteria

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

I am looking for a solution where if i have two fields "Material" and "Machining Number" are already available in table "Sliding" show me that assembly number (field) attached a pic of form for reference.

any help will great!


Private Sub Machine_drawing_Number_AfterUpdate()
Dim MachNum As String
Dim Mat As String
Dim stLinkCriteria1 As String
Dim stLinkCriteria2 As String
Dim Result As String


MachNum = Me.Machine_drawing_Number.Value
Mat = Me.Combo222.Value
Result = Me.Assembly_Drawing_Number.Value

stLinkCriteria1 = "[Machine_drawing_Number]= " & "'" & MachNum & "'"
stLinkCriteria2 = "[Combo222]= " & "'" & Mat & "'"

If Me.Machine_drawing_Number = DLookup("[Assembly Drawing Number]", "SlidingStem_Table", stLinkCriteria1 And stLinkCriteria2) Then
MsgBox "This Machine Drawing No#, " & Result & ", has already been entered in database." _
& vbCr & vbCr & "Please check the Machine no# again.", vbInformation, "Duplicate information."

Me.Undo
End If

End Sub
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    34.6 KB · Views: 120

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top