How can a blank MS Access database be created using VBA?
excel, ms-access, sql, vba
Solution
The name of the locale constant in the CreateDatabase method is wrong:
This: `accessApp.DBEngine.CreateDatabase "C:\tblImport.accdb", dbLangGenera`
Should be: `accessApp.DBEngine.CreateDatabase "D:\tblImport.accdb", DB_LANG_GENERAL`
Change that and your code should work. (It does for me at least).
Problem
I'm a total noob trying to create a blank MS Access database using VBA in Excel. I want to name the new database "tblImport". This is the code I´m using: ``` Sub makedb() Dim accessApp As Access.Application Set accessApp = New Access.Application accessApp.DBEngine.CreateDatabase "C:\tblImport.accdb", dbLangGenera accessApp.Quit Set accessApp = Nothing End Sub ``` I get the following error message: "Run Time Error 3001: Application Defined or Object Defined Error" What can I do?