Create a database using VB Code

  • Thread starter Thread starter Dangermouse
  • Start date Start date
D

Dangermouse

Hi

Using Access 2003

I'm trying to create a database on the fly using VB code, but I am
struggling, and with my knowledge with VB being V little, I feel like I am
drowning.

Via a macro I am calling a procedure, but it fails saying unknown function?,
If I run it manually, the procedure runs but no DB built

here is the code

Public Function CreateDatabase()

Dim db As Database
On Error GoTo ErrorHandler
Set db = DBEngine.CreateDatabase("c\ tmp\mydb.mdb", dbLangGeneral)
CreateDatabase = True
ErrorHandler:
If Not db Is Nothing Then db.Close

End Function

Thanks in advance Dm
 
Hi Dangermouse,

the path you specify in your code (i.e. "c\ tmp\mydb.mdb") is incorrect. It
should be "c:\tmp\mydb.mdb".
Check also that in the References "Microsoft DAO 3.6 object library" is
checked and "Microsoft ActiveX Data Objects 2.1 Library" is unchecked. To see
the references open a VBA windows in your DB select tools and references.

HTH Paolo
 
Back
Top