Just in case someone else needs to do something like this, I ended up changing my code to this:
IF @object_type = '2' AND @transaction_type IN ('U', 'D') BEGIN IF --You can't change unless blank ((SELECT AddID FROM ACRD WHERE CardCode=@list_of_cols_val_tab_del AND loginstanc = (SELECT MAX(ACRD.LogInstanc) FROM ACRD WHERE CardCode=@list_of_cols_val_tab_del)) <> (SELECT AddID FROM OCRD WHERE CardCode=@list_of_cols_val_tab_del) AND (SELECT AddID FROM ACRD WHERE CardCode=@list_of_cols_val_tab_del AND loginstanc = (SELECT MAX(ACRD.LogInstanc) FROM ACRD WHERE CardCode=@list_of_cols_val_tab_del)) <> '') OR --You can't remove ((SELECT AddID FROM OCRD WHERE CardCode=@list_of_cols_val_tab_del) IS NULL AND (SELECT AddID FROM ACRD WHERE CardCode=@list_of_cols_val_tab_del AND loginstanc = (SELECT MAX(ACRD.LogInstanc) FROM ACRD WHERE CardCode=@list_of_cols_val_tab_del)) <> '') BEGIN SET @error =1 SET @error_message = 'You cannot change or delete the BPAY Ref Number. Change it back to ' + (SELECT AddID FROM ACRD WHERE CardCode=@list_of_cols_val_tab_del AND loginstanc = (SELECT MAX(ACRD.LogInstanc) FROM ACRD WHERE CardCode=@list_of_cols_val_tab_del)) + ' and click update again.' END END