i am still very new to all this so please forgive me.
i have a form that gets data from a table and displays it within the form.
what i want it to do before it saves the new data over the original in the record, i want it to copy and paste 3 fields to a 2nd table.
here is the code for the save button ( it just saves the content of a text box on the form for the moment, i just want to see if i can get it to connect to the table and add a record )
but it dosent work all i get is an error message:
what am i doing wrong?
i have attached a copy of the DB if needed.
best regards
i have a form that gets data from a table and displays it within the form.
what i want it to do before it saves the new data over the original in the record, i want it to copy and paste 3 fields to a 2nd table.
here is the code for the save button ( it just saves the content of a text box on the form for the moment, i just want to see if i can get it to connect to the table and add a record )
Code:
Private Sub save_record_Click()
' conenction and recordset object variables
Dim cn As Connection
Dim rs As ADODB.Recordset
Dim Datei As String
Datei = currentdate
' open a connection to the connection object
Set cn = CurrentProject.Connection
' initialise the recordset object
Set rs = New ADODB.Recordset
' using the recordset object
With rs
.Open "history", cn, adOpenStatic, adLockPessimistic ' open it
.AddNew ' prepare to add a new record
.Fields("date") = "Datei"
.Update ' update the table
.Close ' close the recordset connection
End With
End Sub
but it dosent work all i get is an error message:
Error accessing file. Network connection may have been lost.
what am i doing wrong?
i have attached a copy of the DB if needed.
best regards