The same data won't be in two tables. I'd like to add/update data to an existing table.
I've just run up a mock table to test out a method that I found on a different forum, but this adds the data to the table regardless of whether or not it is a duplicate. The code I've used is:
Private Sub cmdAddData_Click()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tblTrial", dbOpenDynaset, dbSeeChanges)
With rs
.AddNew
rs!UniqueID = Me.txtID
rs!Equipment = Me.txtEquipment
rs!Service = Me.txtService
rs!Hydrocarbon = Me.txtHC
rs!AdditionalAccess = Me.txtAccess
rs!Instrument = Me.txtInstrument
rs!ImpulseLineMaterial = Me.txtMaterial
rs!Lagged = Me.txtLag
rs!Tracing = Me.txtTraced
rs!InspectionDate = Me.txtDate
rs!Comments = Me.txtComments
If Me.txtMaterial = "Carbon Steel" Then
rs!MaterialAction = Me.txtCMatRef
Else
rs!MaterialAction = Me.txtSMatRef
End If
If Me.txtMaterial = "Carbon Steel" Then
rs!InsulationAction = Me.txtCInsRef
Else
rs!InsulationAction = Me.txtSInsRef
End If
If Me.txtMaterial = "Carbon Steel" Then
rs!MetallurgyAction = Me.txtCTransRef
Else
rs!MetallurgyAction = Me.txtSTransRef
End If
If Me.txtMaterial = "Carbon Steel" Then
rs!TracingAction = Me.txtCTraceRef
Else
rs!TracingAction = Me.txtSTraceRef
End If
.Update
End With
End Sub
I'm looking elsewhere and it seems like I need to add something that questions whether it's an ".AddNew" or an ".Edit"