Hi all. A new week and a new hurdle for the system I am working on. I am running an "UPSERT/UPPEND" query. I found a couple of resources that detailed the process and it is working exactly as intended. I would like to expand on this query and include a 'conditional update'.
I have an additional field that is part of tbl_AllRequests that I would like to add to this update, but I only want it to update conditionally. I have a field called [sorting_ID]. If the [sorting_ID] field has been selected (it is a lookup field), then I do NOT want the UPSERT query to update anything.
Here is the logic:
- Run UPSERT query
- Update records IF [sorting_ID] is null/unchanged.
Context:
tbl_OutlookLink is a linked table that monitors an Outlook folder. I have a menu with a button that runs the UPSERT query. The idea behind the UPSERT query is if there is a new email in the linked folder, it will update and add it to tbl_AllRequests.
Hopefully all that makes sense. Thanks in advance for your assistance.
SQL:
UPDATE tbl_OutlookLink LEFT JOIN tbl_AllRequests ON tbl_OutlookLink.Received = tbl_AllRequests.date_rec SET tbl_AllRequests.email_sender = [tbl_OutlookLink].[From], tbl_AllRequests.date_rec = [tbl_OutlookLink].[Received], tbl_AllRequests.email_contents = [tbl_OutlookLink].[Contents], tbl_AllRequests.email_subject = [tbl_OutlookLink].[Normalized Subject];
I have an additional field that is part of tbl_AllRequests that I would like to add to this update, but I only want it to update conditionally. I have a field called [sorting_ID]. If the [sorting_ID] field has been selected (it is a lookup field), then I do NOT want the UPSERT query to update anything.
Here is the logic:
- Run UPSERT query
- Update records IF [sorting_ID] is null/unchanged.
Context:
tbl_OutlookLink is a linked table that monitors an Outlook folder. I have a menu with a button that runs the UPSERT query. The idea behind the UPSERT query is if there is a new email in the linked folder, it will update and add it to tbl_AllRequests.
Hopefully all that makes sense. Thanks in advance for your assistance.