conditional macro

  • Hi all,


    I have a macro that I've copied straight off the microsoft website. The code checks the invoice number entered on a form to see if it already exists in the underlying table, thus to avoid duplication. The macro is called by the "before update" event of the invoice number. I have tried to modifty this code to look at 2 fields, that is the invoice number AND the supplier name. All fields are text fields.


    Attached the first bit that works. This is placed under the "condition" column on the macro design screen, having MSGBOX as the action.

    Code
    DLookUp("[InvoiceNO]","[Invoice log table]","[InvoiceNO] = Form.[InvoiceNO] ") Is Not Null


    And i've tried to add the 2nd field but this is no longer doing any validation. I've also moved the macro to the supplier name "before update" event, as the invoice number gets entered first.

    Code
    DLookUp("[InvoiceNO]","[Invoice log table]","[InvoiceNO] = '" & Forms![Invoice Log Table 4]![InvoiceNO]  & "'" & " AND [Supplier Name]= '" & Forms![Invoice Log Table 4]![Supplier Name] & "'") Is Not Null

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!