Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("CustomerRelatedCompanies")
AnotherRecord:
rs.AddNew
rs!CustomerNo = Me.Combo0.Value
rs!RelatedCustomerNo = Me.Combo2.Value
rs!RelationType = Me.List4.Value
rs.Update
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
If Err.number = 3022 Then
MsgBox "That record already exists in the table. Proceed to another record"
rs.CancelUpdate
Else
MsgBox Err.number & " " & Err.Description
End If
Resume Exit_Command6_Click
End Sub