Each of the fields in the tables of my database are updatable, but when I create a recordset using the following code, the fields are not updatable. I get Error #3027, Can't update...Object is read only on line #80.
Can anybody tell me why, and what I can do about it.
Public Sub DeleteCat()
On Error GoTo DeleteError
Dim FilteredSet As Recordset, SQL As String
10 Call OpenMyRecordsets
20 SQL = "SELECT Headings.Title, Headings.LineTwo, Headings.LastLine, Names.BallotNumber , Names.CatID , Names.Ballotpage , Candidate , Party "
30 SQL = SQL & " FROM Names INNER JOIN Headings ON Names.CatID = Headings.CatID "
40 SQL = SQL & " WHERE Names.CatID = " & txtCatID.Text & " And Names.BallotNumber = '" & TxtBallot.Text & "' AND Names.BallotPage = '" & TxtPage.Text & "'"
50 Set FilteredSet = MyFirstDB.OpenRecordset(SQL, dbOpenDynaset)
'Delete all records for this category
60 FilteredSet.MoveFirst
70 Do While Not FilteredSet.EOF
80 FilteredSet.Delete
90 FilteredSet.MoveNext
100 Loop
Exit Sub
DeleteError:
MsgBox "Error #" & Err.Number & Error & " on line #" & Erl
End Sub
Can anybody tell me why, and what I can do about it.
Public Sub DeleteCat()
On Error GoTo DeleteError
Dim FilteredSet As Recordset, SQL As String
10 Call OpenMyRecordsets
20 SQL = "SELECT Headings.Title, Headings.LineTwo, Headings.LastLine, Names.BallotNumber , Names.CatID , Names.Ballotpage , Candidate , Party "
30 SQL = SQL & " FROM Names INNER JOIN Headings ON Names.CatID = Headings.CatID "
40 SQL = SQL & " WHERE Names.CatID = " & txtCatID.Text & " And Names.BallotNumber = '" & TxtBallot.Text & "' AND Names.BallotPage = '" & TxtPage.Text & "'"
50 Set FilteredSet = MyFirstDB.OpenRecordset(SQL, dbOpenDynaset)
'Delete all records for this category
60 FilteredSet.MoveFirst
70 Do While Not FilteredSet.EOF
80 FilteredSet.Delete
90 FilteredSet.MoveNext
100 Loop
Exit Sub
DeleteError:
MsgBox "Error #" & Err.Number & Error & " on line #" & Erl
End Sub