PC Review


Reply
Thread Tools Rate Thread

Create a database using VB Code

 
 
Dangermouse
Guest
Posts: n/a
 
      10th Mar 2009
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

 
Reply With Quote
 
 
 
 
Paolo
Guest
Posts: n/a
 
      10th Mar 2009
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

"Dangermouse" wrote:

> 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
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create A Database with VB Code Dangermouse Microsoft Access VBA Modules 1 10th Mar 2009 06:21 PM
create new blank database by VBA code =?Utf-8?B?Vi5QLg==?= Microsoft Access VBA Modules 5 31st Aug 2006 11:01 PM
Create a database in code =?Utf-8?B?U2FyYWg=?= Microsoft Access Form Coding 12 7th Jun 2006 10:25 PM
how do I create a database using post code =?Utf-8?B?S2V2YW53?= Microsoft Access Queries 1 30th Mar 2006 01:21 AM
Can't create new database using VBA code Robert Microsoft Access Database Table Design 5 10th Dec 2003 01:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:42 AM.