Experts:
I have a question about updating some table references/records. Hopefully someone could assist me with some UPDATE query.
Background:
- I have a "Archive Record" button on a form.
- I pressed (and confirmed), the boolean value TRUE will be set to FALSE based on the VBA (line #1). This works fine.
What I'd like to Accomplish:
- I'd like to also update the junction table (with lines 2 and 3). These two lines are executed w/o errors if the RecordIDpk exists.
- However, I just realized that not all staff members have a record ID in the junction tables. There are scenarios where they may have a record in T00_JunctionTable_BCFT AND/OR in T00_JunctionTable_BOPT.
Right now, if no record exists the record (obviously) cannot be updated. My question: How can I, e.g., use an IF statement (only for VBA lines 2 and 3 below) in the event a record exist in neither both tables nor in T00_JunctionTable_BCFT nor in T00_JunctionTable_BOPT?
Code:
CurrentDb.Execute "UPDATE T01_StaffMembers SET T01_StaffMembers.All_Onboard = False WHERE (((T01_StaffMembers.StaffMemberIDpk)=" & StaffMemberIDpk & "))"
CurrentDb.Execute "UPDATE T00_JunctionTable_BCFT SET T00_JunctionTable_BCFT.RecordIDfk = 1 WHERE (((T00_JunctionTable_BCFT.RecordIDfk)=" & Me.RecordIDpk & "))"
CurrentDb.Execute "UPDATE T00_JunctionTable_BOPT SET T00_JunctionTable_BOPT.RecordIDfk = 1 WHERE (((T00_JunctionTable_BOPT.RecordIDfk)=" & Me.RecordIDpk & "))"