Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Mar 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel to Access (VBA/Excel/2003)

    Can Excel VBA be used to create a (new) table in an Access database?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Excel to Access (VBA/Excel/2003)

    Strictly speaking, no, since Excel VBA doesn't know anything about Access. But you can set a reference in Tools | References... to the Microsoft DAO 3.6 Object Library and use that to manipulate a database. Example: create a table tblTest in the database C:AccessTest.mdb with two text fields, LastName (size 20) and FirstName (size 10).

    Sub CreateATable()
    Dim dbs As DAO.Database
    Dim strSQL As String
    Set dbs = DAO.DBEngine.OpenDatabase("C:AccessTest.mdb")
    strSQL = "CREATE TABLE tblTest " & _
    "(LastName TEXT(20), FirstName TEXT(10))"
    dbs.Execute strSQL, dbFailOnError
    dbs.Close
    Set dbs = Nothing
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Mar 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel to Access (VBA/Excel/2003)

    Thanks.

Posting Permissions

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