Reputation: 1
In my code I'm creating a new database and then using DoCmd.TransferDatabase to copy some tables into it. This used to work with no issues, now I'm getting the error: "Run-time error '3709': The search key was not found in any record. My code is:
Set db = DBEngine.CreateDatabase(sPath, dbLangGeneral)
DoCmd.TransferDatabase acExport, "Microsoft Access", sPath, acTable,
"MATerials", "MAT", False
DoCmd.TransferDatabase acExport, "Microsoft Access", sPath, acTable,
"new_2Kilo", "TWOK", False
DoCmd.TransferDatabase acExport, "Microsoft Access", sPath, acTable,
"tblCSMP", "tblCSMP", False
DoCmd.TransferDatabase acExport, "Microsoft Access", sPath, acTable,
"tblICMP", "tblICMP", False
DoCmd.TransferDatabase acExport, "Microsoft Access", sPath, acTable,
"tblMARMC_USERS", "tblMARMC_USERS", False
DoCmd.TransferDatabase acExport, "Microsoft Access", sPath, acTable,
"tblVisit_Personnel", "tblVisit_Personnel", False
DoCmd.TransferDatabase acExport, "Microsoft Access", sPath, acTable,
"Training", "Training", False
DoCmd.TransferDatabase acExport, "Microsoft Access", sPath, acTable,
"tblTeamMember", "tblTeamMember", False
DoCmd.TransferDatabase acExport, "Microsoft Access", sPath, acTable,
"WORK_NOTIFICATIONS", "WORK_NOTIFICATIONS", False
If I open the newly created database and click the "Enable Content" button the function will continue. Any ideas how to work around this?
Upvotes: 0
Views: 1760
Reputation: 32642
Untrusted locations can't be exported to using DoCmd.TransferDatabase
.
Afaik however, you can export to them just fine using queries, as these are processed on the database engine level, not the application level, and trust issues are at the application level.
To write a query that exports a table:
SELECT * INTO [;DATABASE=C:\Path\To\File.accdb].NewTableName FROM OldTableName
Note that this only exports data and not related information (indexes, which columns are visible, lookups, etc) and thus is functionally different.
Upvotes: 1