dimanche 5 août 2018

How to combine multiple If statements/Dlookup functions?

I have the following code that I am running when a button is clicked on a Form:

If DLookup("ECN_Class_I_Change", "ENGINEERING_CHANGE_NOTICE_TABLE", "[ECN_Class_I_Change] = -1") Then
If DLookup("ECN", "ENGINEERING_CHANGE_NOTICE_TABLE", "'ECN' = 'Forms!DRAWING_INFO_FORM!Subform_DRAWING_STATUS!Subform_DRAWING_STATUS_ECN!ECN'") Then
strMessage = "Change third digit."
MsgBox strMessage, vbInformation, "Action Required"
    Else
        If DLookup("PCP", "REVIEW_PANEL_TABLE", "[PCP] = -1") Then
        If DLookup("GWSHW_BL", "REVIEW_PANEL_TABLE", "'[GWSHW_BL]' = 'Forms!DRAWING_INFO_FORM!Subform_DRAWING_STATUS!Subform_DRAWING_STATUS_CONFIGURATION_HWCI_BL!BL_HWCI_HWCI'") Then
        If DLookup("GWSHW_HW", "REVIEW_PANEL_TABLE", "'[GWSHW_HW]' = 'Forms!DRAWING_INFO_FORM!Subform_DRAWING_STATUS!Subform_DRAWING_STATUS_CONFIGURATION_HWCI_BL!BL_HWCI_HWCI'") Then
            strMessage = "Change fourth digit - HWCI/BL has been certified."
            MsgBox strMessage, vbInformation, "Action Required"
            Else
                strMessage = "Change fifth digit"
                MsgBox strMessage, vbInformation, "Action Required"

The code is not throwing any errors, but is not resulting in the expected behavior. I am fairly confident the issue is from combining multiple If/Dlookup functions consecutively. I have only ever coded using one at a time, so I am not sure how to combine these since it is not just multiple criteria of one Dlookup, but multiple Dlookup statements.

Any assistance would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire