I have the following code:
Sub CreateAccessDatabase()
Dim accessApp As Object
Dim dbs As Object
On Error Resume Next
Set accessApp = GetObject(, "Access.Application")
If accessApp Is Nothing Then Set accessApp = CreateObject("Access.Application")
If accessApp Is Nothing Then Exit Sub
On Error GoTo 0
accessApp.DBEngine.CreateDatabase "TempData.accdb", accessApp.dbLangGeneral
Set dbs = accessApp.CurrentDb
MsgBox dbs.Name ' Used to verify that the database was actually created
accessApp.Quit
Set dbs = Nothing
Set accessApp = Nothing
End Sub
I receive the following error message when the accessApp.DBEngine.CreateDatabase... line is executed:
Run-time error 438: Object doesn't support this property or method.
Can someone please tell me how to fix the aforementioned line so that it successfully executes? Thanks in advance for any assistance.