I have an add form which is supposed to take the info input into a form and then add it to an existing table.
Here is the code that I've used:
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tbl06ButamerAllLines", dbOpenDynaset, dbSeeChanges)
With rs
.Edit
rs!UniqueID = Me.txtID
rs!EquipmentNo = Me.txtEquipment
rs!Service = Me.txtService
rs!HydrocarbonsPresent = Me.txtHC
rs!AdditionalAccess = Me.txtAccess
rs!InstrumentType = Me.txtInstrument
rs!ImpulseLineMaterial = Me.txtMaterial
rs!Lagged = Me.txtLag
rs!Traced = Me.txtTraced
rs!DateOfInspection = Me.txtDate
rs!DueDate = Me.txtNewDate
rs!Comments = Me.txtComments
rs!MatActionDueDate = Me.txtMatDate
rs!InsActionDueDate = Me.txtInsDate
rs!TransActionDueDate = Me.txtTransDate
rs!TraceActionDueDate = Me.txtTraceDate
rs!AdditionalAccessToBeInstalled = Me.txtAccess
'Tells the program to add the action dependent on the material
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!TransitionAction = Me.txtCTransRef
Else
rs!TransitionAction = Me.txtSTransRef
End If
If Me.txtMaterial = "Carbon Steel" Then
rs!TracingAction = Me.txtCTraceRef
Else
rs!TracingAction = Me.txtSTraceRef
End If
.Update
.Close
End With
What's happening is only the first record on my form is being edited. How do I get it to only update at a certain point, this case being "Unique ID", essentially overwriting all previous info at a certain common point?
Here is the code that I've used:
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tbl06ButamerAllLines", dbOpenDynaset, dbSeeChanges)
With rs
.Edit
rs!UniqueID = Me.txtID
rs!EquipmentNo = Me.txtEquipment
rs!Service = Me.txtService
rs!HydrocarbonsPresent = Me.txtHC
rs!AdditionalAccess = Me.txtAccess
rs!InstrumentType = Me.txtInstrument
rs!ImpulseLineMaterial = Me.txtMaterial
rs!Lagged = Me.txtLag
rs!Traced = Me.txtTraced
rs!DateOfInspection = Me.txtDate
rs!DueDate = Me.txtNewDate
rs!Comments = Me.txtComments
rs!MatActionDueDate = Me.txtMatDate
rs!InsActionDueDate = Me.txtInsDate
rs!TransActionDueDate = Me.txtTransDate
rs!TraceActionDueDate = Me.txtTraceDate
rs!AdditionalAccessToBeInstalled = Me.txtAccess
'Tells the program to add the action dependent on the material
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!TransitionAction = Me.txtCTransRef
Else
rs!TransitionAction = Me.txtSTransRef
End If
If Me.txtMaterial = "Carbon Steel" Then
rs!TracingAction = Me.txtCTraceRef
Else
rs!TracingAction = Me.txtSTraceRef
End If
.Update
.Close
End With
What's happening is only the first record on my form is being edited. How do I get it to only update at a certain point, this case being "Unique ID", essentially overwriting all previous info at a certain common point?
Last edited: