Hi All
I am trying to update some records on my form.
The forms connect the fields in table 1 to the fields in my form.
When i try to make modifcations to the fields on my form, it wont update the table thats its connected to.
It says 'Fields cannot be updated'
What is the problem?
I am trying to update some records on my form.
The forms connect the fields in table 1 to the fields in my form.
When i try to make modifcations to the fields on my form, it wont update the table thats its connected to.
It says 'Fields cannot be updated'
What is the problem?
Code:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub btnNext_Click()
UpdateRecords
rs.MoveNext
If rs.EOF Then
rs.MoveLast
End If
FillControls
End Sub
Private Sub btnPrevious_Click()
UpdateRecords
rs.MoveNext
If rs.BOF Then
rs.MoveFirst
End If
FillControls
End Sub
Private Sub Form_Load()
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
rs.Open "Table1", cn, adOpenDynamic, adLockBatchOptimistic
FillControls
End Sub
Sub FillControls()
txtID.SetFocus
txtID.Text = rs.Fields.Item("ID")
txtForename.SetFocus
txtForename.Text = rs.Fields.Item("Forename")
txtSurename.SetFocus
txtSurename.Text = rs.Fields.Item("Surename")
End Sub
Sub UpdateRecords()
txtID.SetFocus
rs.Fields.Item("ID") = txtID.Text
txtForename.SetFocus
rs.Fields.Item("Forename") = txtForename.Text
txtSurename.SetFocus
rs.Fields.Item("Surname") = txtSurename.Text
rs.UpdateBatch
End Sub