I am using the following code to open an external database and add a record to a table in it.
strTableName = "flkpTable1"
strDBName = "C:\Program Files\Database.MDB"
Set dbImp = DBEngine.Workspaces(0).OpenDatabase strDBName, False, True,
"'")
Set rsImp = dbImp.OpenRecordset(strTableName, dbOpenDynaset)
rsImp.FindFirst "Field1 = '" & Variable1 & "'"
If rsImp.NoMatch Then
rsImp.AddNew
The code works fine until I get to the AddNew portion. I get an error message telling me Cannot update, Database or Object is Read-Only. The database is not read only unless I am opening it incorrectly. Can anybody see what's wrong with my code?
Thanks
strTableName = "flkpTable1"
strDBName = "C:\Program Files\Database.MDB"
Set dbImp = DBEngine.Workspaces(0).OpenDatabase strDBName, False, True,
"'")
Set rsImp = dbImp.OpenRecordset(strTableName, dbOpenDynaset)
rsImp.FindFirst "Field1 = '" & Variable1 & "'"
If rsImp.NoMatch Then
rsImp.AddNew
The code works fine until I get to the AddNew portion. I get an error message telling me Cannot update, Database or Object is Read-Only. The database is not read only unless I am opening it incorrectly. Can anybody see what's wrong with my code?
Thanks