Create a database using VB Code

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
 
P

Paolo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top