Another day - Another problem !
I have a A97 front-end to a SQL Server back-end.
I am trying to add a new record to a table using the following code:
Private Sub cmdNewAction_Click()
Dim wsp As Workspace
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set wsp = DBEngine(0)
Set db = wsp.OpenDatabase(Name:="", Options:=False, ReadOnly:=False, Connect:=G_CONNECTION)
Set rst = db.OpenRecordset("select tblTask.* from tblTask", dbOpenDynaset, dbSeeChanges, dbPessimistic)
rst.AddNew
rst!ProjectID = Forms!frmProject!ProjectID
rst!ActionOpenDate = CDate(Int(CDbl(Now)))
rst.Update
Me.Requery
End Sub
My wsp and db definition I think are correct because they work elsewhere for reading records.
G_CONNECTION is a global constand defining my ODBC connection details.
When I reach the rst.AddNew command, I get a message
"Run Time Error 3027 : Can't Update - Database or Object is Read-only"
I can manually add records to the table, so I believe the problem is in the OpenRecordset line.
I've scanned the Help files and these forums, tried many combinations of options, but can not find where the problem is.
Can anyone see why this is not working ?
Any help as usual is much appreciated.
Aidan Hughes
I have a A97 front-end to a SQL Server back-end.
I am trying to add a new record to a table using the following code:
Private Sub cmdNewAction_Click()
Dim wsp As Workspace
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set wsp = DBEngine(0)
Set db = wsp.OpenDatabase(Name:="", Options:=False, ReadOnly:=False, Connect:=G_CONNECTION)
Set rst = db.OpenRecordset("select tblTask.* from tblTask", dbOpenDynaset, dbSeeChanges, dbPessimistic)
rst.AddNew
rst!ProjectID = Forms!frmProject!ProjectID
rst!ActionOpenDate = CDate(Int(CDbl(Now)))
rst.Update
Me.Requery
End Sub
My wsp and db definition I think are correct because they work elsewhere for reading records.
G_CONNECTION is a global constand defining my ODBC connection details.
When I reach the rst.AddNew command, I get a message
"Run Time Error 3027 : Can't Update - Database or Object is Read-only"
I can manually add records to the table, so I believe the problem is in the OpenRecordset line.
I've scanned the Help files and these forums, tried many combinations of options, but can not find where the problem is.
Can anyone see why this is not working ?
Any help as usual is much appreciated.
Aidan Hughes