Access DLookup Function – more than 1 criteria

Access Discussion in 'Microsoft Office' started by Parminder Singh, May 18, 2017.

  1. Parminder Singh

    Parminder Singh

    May 18, 2017
    Likes Received:
    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."

    End If

    End Sub

    Attached Files:

    Parminder Singh, May 18, 2017
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.