I am sure the records are saved because I can see them in the table - they only disappear later. I have added the code used to add records to the tblSKAProcessesLink as well as tblSKARolesLink, and attached a picture of the relationships in case that helps. The only table that is losing records is tblSKAProcessesLink.
Private Sub cmdLinkProcess_Click()
Dim ProcessChoices As ListBox
Dim AddSQL As String
Dim CurrentRow As Integer
Dim SKAID As Long
SKAID = Me.SKAID
Set ProcessChoices = Me.lstAvailableProcesses
For CurrentRow = 0 To ProcessChoices.ListCount - 1
If ProcessChoices.Selected(CurrentRow) Then
AddSQL = "INSERT INTO tblSKAProcessesLink (ProcessID, SKAID) VALUES (" & ProcessChoices.ItemData(CurrentRow) & ", " & SKAID & ")"
'DoCmd.SetWarnings (False)
DoCmd.RunSQL (AddSQL)
'DoCmd.SetWarnings (True)
End If
Next CurrentRow
Me.lstLinkedProcesses.Requery
Me.lstAvailableProcesses.Requery
End Sub
Private Sub cmdLinkRole_Click()
Dim RoleChoices As ListBox
Dim AddSQL As String
Dim CurrentRow As Integer
Dim PRow As Integer
Dim SKAID As Long
Dim ProcessLinkChoices As ListBox
Dim ProcessID As Long
SKAID = Me.SKAID
Set RoleChoices = Me.lstAvailableRoles
Set ProcessLinkChoices = Me.lstLinkedProcesses
For PRow = 0 To ProcessLinkChoices.ListCount - 1
If ProcessLinkChoices.Selected(PRow) Then
ProcessID = ProcessLinkChoices.ItemData(PRow)
For CurrentRow = 0 To RoleChoices.ListCount - 1
If RoleChoices.Selected(CurrentRow) Then
AddSQL = "INSERT INTO tblSKARolesLink (RoleID, SKAID, ProcessID) VALUES (" & RoleChoices.ItemData(CurrentRow) & ", " & SKAID & "," & ProcessID & ")"
'DoCmd.SetWarnings (False)
DoCmd.RunSQL (AddSQL)
'DoCmd.SetWarnings (True)
End If
Next CurrentRow
End If
Next PRow
Me.lstLinkedRoles.Requery
Me.lstAvailableRoles.Requery
End Sub