Results 1 to 2 of 2

Thread: How to create a msaccess database?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    118

    Post

    Hi
    I am trying to figure out how to create a MS Access database from a file (with code not from within access).This file has many lines in it. Can anyone help me to get started? Each line will have 3 to 4 fields in it. Any help would be appreciated.

  2. #2
    Addicted Member Geoff Gunson's Avatar
    Join Date
    Jun 1999
    Posts
    241

    Post

    Hi heres the code that I am using to dynamically create a database, I can't claim any credit as it was an example on this site.

    Don't forget get to reference the DAO object.

    Hope it helps

    Geoff

    Dim wrkDefault As Workspace
    Dim newConfig As Database
    Dim SQLstr As String

    On Error GoTo ERRdataBase

    Set wrkDefault = DBEngine.Workspaces(0)
    Set newConfig = wrkDefault.CreateDatabase(DEFAULTcfg, dbLangGeneral)

    With newConfig

    'create a tabled called TableY with two feilds

    SQLstr = "CREATE TABLE TableY (FirstName TEXT, LastName TEXT);"
    .Execute SQLstr
    .Close

    End With



    Exit Sub
    ERRdataBase:
    MsgBox Err.Description & " " & Err.Number

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