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!

External db not Updatable

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
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

 
The database may not be read only, but you are specifying the Read Only flag as True in the OpenDatabase statement, so Access won't let you add or update data in it.

If you change the True statement to False, it should work correctly (provided that the file is not read only on the disk or secured with NTFS permissions).

John
 
Thank you, Eddy. Can you explain the line of code for me?

Set dbImp = DBEngine.Workspaces(0).OpenDatabase strDBName, False, True,
"'")

Vast02
 
The Workspaces collection (and how to use it) is thoroughly explained in the Access help files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top