Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error #3027 Can't Update Records of Dynaset

Status
Not open for further replies.

Weltman

Programmer
Apr 27, 2001
17
US
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
 
In case anybody is interested, the answer is:
Include the option "dbInconsistent" in OpenRecordset,
on line# 50.
50 Set FilteredSet = MyFirstDB.OpenRecordset(SQL, dbOpenDynaset, dbInconsistent)

Weltman
 
Weltman,
I noticed that in your code your database is named 'MyFirstDB' which leads me to believe that you are just learning VB. Might I suggest that you focus on ADO rather than DAO. ADO is more robust and stable, and as far as future VB versions, you can lok for DAO to be all but phased out. Even now .NET will not allow data binding in DAO.
 
woyler:
Actually, I first started programming in VB when there
first was such a thing, but I'm a few years out-of-date
and still using the books for VB4.
The reason I named the database "MyFirstDB" was because
there will be more than one database used with this application.
Anyway, thanks for the advice.
Weltman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top