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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error 3027

Status
Not open for further replies.

KerryL

Technical User
May 7, 2001
545
US
My program keeps crashing at a simple line of code that does nothing more than add the date to the field on a form. The reason I can't figure out why is because I have two versions of this program and it works just fine in the other one.

Here's the error message:

Run-timer error '3027':
Cannot update. Database or object is read only.


Line of code in question:

'Update date field
.Edit
.Fields("EmailToCardHolders") = Date
.Update
 
which version is working? is the version with the problem a read-only ?
also check the properties of the .mdb file: in windows explorer right-click on the file and make sure the Read-Only is not Checked.
 
I think EasyTarget is on the right track. If you have a record from a table current on a form then the record is in an edit mode. When you try to write the code to update the date field directly to the table the record is locked and only allows your recordset code to run in read-only mode.

Why not just change the form control and perform a save of the record on the form? This way the date field is updated and is active on the form.

Bob Scriver
 
Well, I checked everything you guys suggested. The database file property isn't set to read-only.

The control on the form was bound to a field in the table, so I made it unbound. I still received the error.

Still working on it....
 
u posted:
.Edit
.Fields("EmailToCardHolders") = Date
.Update

can u post the "with" statement and the recordset definition?
maybe u opened ur recordset as "snapshot" type.
 
Access by default will open the recordset in Read Only mode. You need to ensure that the you open it in Edit mode.

Something like this:

With rst_YourRecordSet
Set .ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.Open "tbl_YourTable", LockType:=adLockOptimistic
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top