Results 1 to 3 of 3

Thread: How can i create DB Access at runtime ?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Belgium
    Posts
    8

    Cool

    Hi all !!!

    How can i create an empty *.mdb file (no tables, no reports, ...) at runtime with VB?

    Thanx !


  2. #2

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Belgium
    Posts
    8
    Very simple pooni :

    you must declare an object Access.Application (the reference to Micro$oft Access must be set before). The code must be like this:

    Code:
    set mdbApp = CreateObject("Access.Application")
    mdbApp.NewCurrentDatabase (App.Path & "\" & "Test.mdb")
    set mdbApp = Nothing

    And then you'll have an empty DB Access in your application path ...

    [Edited by pooni on 05-24-2000 at 08:50 AM]

  3. #3

    Thumbs up

    Hi Pooni

    The above code works only when the Access is installed in your machine.

    Try the following.
    Set a refernce to Microsoft Data Access Objects 3.6 in The Project --> References.

    Use the following code

    Code:
    Dim db As DAO.Database
    Dim NewDatabaseFilePath As String
    NewDatabaseFilePath = "c:\test.mdb"    'You can give your own path
    Set db = CreateDatabase(NewDatabaseFilePath, dbLangGeneral)    'This will create a new test.mdb file
    db.Close
    Set db = Nothing
    ALL THE BEST

    Madhusudana Gorthi [email protected]
    Senior Software Engineer
    www.stgil.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width