John:
I spent quite some time trying to figure out the update process (i.e., reassigning ID numbers). I finally got this to work... it is a somewhat complex process and describing it in detail is outside the scope of this thread. For general sync purposes, however, I will describe the general process:
1. The form describes a "Billet" (job) as shows the organization that currently "owns" the job + the billet ID (job #).
2. The "GoTo" combo box shows who (employee) currently in that billet/job.
3. At some point, an employee may gets promoted and moves into another position.
4. So, when I move the employee into a different branch and job, I need to put a "Vacant" (employee ID = 1) into the current position.
So, again, my update process works as envisioned and I do NOT need to make changes to it. However, when I move the employee, the name now shows "Vacant" given that the form shows the StaffMember ID.
So, once I moved, e.g., Mike Abraham, I want to follows his StaffMember ID in the form (vs. staying on ID = 1 or "Vacant").
Again, your process of caching the StaffMember's ID works fine. I simply can't figure out how to "follow" Mike Abraham... either via the StaffID or via the RecordID?
Code:
Private Sub cboMoveStaffMember_Click()
Dim Old_StaffMemberIDpk As Long
Old_StaffMemberIDpk = StaffMemberIDpk
'If user presses "Yes", then Staffmember will be reassigned to a different organization and either a) receive new BIN or b) keep existing BIN
If MsgBox("Are you sure you want to move " & Auto_Title0 & " into the new organization?", vbYesNo + vbQuestion) <> vbNo Then
'PROCESS #1: User only select new N-code but leaves BIN empty
If IsNull(BilletIDfk_New) = True Then
'If BIN is left empty (i.e., staff member keeps his current BIN), then only the organization value is updated.
CurrentDb.Execute "UPDATE T00_JunctionTable_OBS SET T00_JunctionTable_OBS.OrganizationIDfk = " & OrganizationID_New & " WHERE (((T00_JunctionTable_OBS.RecordIDpk)=" & RecordIDpk & "));"
CurrentDb.Execute "UPDATE T00_JunctionTable_OBS SET T00_JunctionTable_OBS.Record_Modified_Date = Now() WHERE (((T00_JunctionTable_OBS.RecordIDpk)=" & RecordIDpk & "));"
'Throw message upon successful move
MsgBox Auto_Title0 & " has been successfully moved into the new organization!", vbInformation, "Information"
Else
'Do nothing
End If
'PROCESS #2: User selected both new N-code and new BIN
If IsNull(N_Code_New) Or IsNull(BilletIDfk_New) = True Then
'Do nothing
Else
'Step 1: Insert "[Vacant]" (StaffMemberIDfk = 1) into the OBS table of staff member's current billet (and update date time stamp in the OBS record)
CurrentDb.Execute "UPDATE T00_JunctionTable_OBS SET T00_JunctionTable_OBS.StaffMemberIDfk = 1 WHERE (((T00_JunctionTable_OBS.RecordIDpk)=" & RecordIDpk & "));"
CurrentDb.Execute "UPDATE T00_JunctionTable_OBS SET T00_JunctionTable_OBS.Record_Modified_Date = Now() WHERE (((T00_JunctionTable_OBS.RecordIDpk)=" & RecordIDpk & "));"
'Step 2: Insert StaffMemberIDfk into the OBS table of the new position (and update date time stamp in the OBS record)
CurrentDb.Execute "UPDATE T00_JunctionTable_OBS SET T00_JunctionTable_OBS.StaffMemberIDfk = " & StaffMemberIDpk & " WHERE (((T00_JunctionTable_OBS.BilletIDfk)=" & BilletIDfk_New_Cache & "));"
CurrentDb.Execute "UPDATE T00_JunctionTable_OBS SET T00_JunctionTable_OBS.Record_Modified_Date = Now() WHERE (((T00_JunctionTable_OBS.RecordIDpk)=" & BilletIDfk_New_Cache & "));"
'Requery combo boxes for 'current organization'
Me.N_Code_Current.Requery
Me.OrgName_Current.Requery
Me.Ra_BIN_Current.Requery
Me.Ra_Billet_Title_Current.Requery
'Empty combo boxes for 'new organization'
Me.N_Code_New.Value = Null
Me.BilletIDfk_New.Value = Null
'Throw message upon successful move
MsgBox Auto_Title0 & " has been successfully moved into the new organization and BIN has been updated!", vbInformation, "Information"
'After update, move to first record in the form's record set
DoCmd.GoToRecord acDataForm, "F11_Reassign_StaffMember_Different_Org", acGoTo, 1
End If
End If
End Sub
Right now, I simply navigate to the first record... (acGoTo, 1) but that's not the method I want to use in this process.