Hello Accessers,
I am attempting to find the flaw in the code below after an error pops up: "Run-time error '3207': Cannot update. Database or object is read-only." At the beginning of debugging process, I am being led to RS.Edit where it is highlighted.
Any ideas?
Code:
Public Function FlawCode() Dim i As Long
With Screen.ActiveForm.[FieldABC]
Dim stNextUser As String
Dim MyDB As Database, RS As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
stNextUser = ""
Set RS = MyDB.OpenRecordset("select * from qryName_Type")
lngRSCount = RS.RecordCount
If lngRSCount <> 0 Then
RS.MoveFirst
stNextUser = Trim(RS.Fields("ABC").Value)
RS.Edit
RS.Fields("DateABC").Value = Now()
RS.Update
RS.Close
MyDB.Close
Else
RS.Close
stMsg = MsgBox("An error has occured", vbCritical)
MyDB.Close
End If
DoCmd.GoToRecord , , acNewRec
For i = 0 To .ListCount
If .ItemData(i) = stNextUser Then
.Value = stNextUser
MsgBox "Hi", vbApplicationModal
End If
Next i
End With
End Function