I have some different controls on a form (textboxes, checkboxes etc). When I press a button, I want to insert whats in the controls in a table. Below code is what I have on that (it seems to work fine):
----------
Private Sub Cmdaddnew_Click()
Set db = CurrentDb
Set rs = db.OpenRecordset("tblvessels")
With rs
.AddNew
.Fields("VesselID") = Me.txtvesselid.Value
.Fields("Vesselname") = Me.Txtvslname.Value
.Fields("Ongoing") = Me.Chkongoing.Value
.Update
End With
End Sub
----------
I have a few questions.
1. If I want to Edit an existing record, in stead of adding it, how does that look in code?
2. Above only adds a record in one table. What do I do, if I want to update two tables, and the the fields "VesselID" and "Vesselname" are in both the tables?
Pls help, since I'm a bit stuck.
----------
Private Sub Cmdaddnew_Click()
Set db = CurrentDb
Set rs = db.OpenRecordset("tblvessels")
With rs
.AddNew
.Fields("VesselID") = Me.txtvesselid.Value
.Fields("Vesselname") = Me.Txtvslname.Value
.Fields("Ongoing") = Me.Chkongoing.Value
.Update
End With
End Sub
----------
I have a few questions.
1. If I want to Edit an existing record, in stead of adding it, how does that look in code?
2. Above only adds a record in one table. What do I do, if I want to update two tables, and the the fields "VesselID" and "Vesselname" are in both the tables?
Pls help, since I'm a bit stuck.