Create a table in Access using VBA, from data in excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • teneesh
    New Member
    • Mar 2007
    • 46

    Create a table in Access using VBA, from data in excel

    I'm attempting something new, in trying to create a table in VBA coming from excel. I saw an example using ADOB but I don't want to use that, just some plain script.

    I've set up this example to attempt to do it myself and once I can figure it out, I can go into production . . . please help me get rid of the ADOB thing and find a better way.
    Thanks,


    Sub CreateTable_for TP_Table()


    Dim rstSubjectProp, rstMarkerScore, rstStatistics, rstEpochbEpoch, rstAnalysisInpu t As Recordset
    'subject properties table
    Dim SubjectID As String ' Identity
    Dim Initials As String
    Dim Gender As String
    Dim Age As Integer
    Dim AgeExportCreati on As Integer
    Dim DateOfBirth As String
    Dim New_TablePath As String
    'Dim TP As ADODB.catalog
    'Dim tbl As ADODB.Table

    New_TablePath = "S:\\ Go To Sleep\Import Data Code\Statistics Table.xlsx"

    On Error Resume Next
    Kill New_TablePath
    On Error GoTo 0

    'create the table
    Set tbl = New ADODB.Table
    tbl.Name = "tblPopulat ion"

    'creating new fields
    tbl.columns.App end "SubjectID" , adString
    tbl.columns.App end "Initials", adString

    cat.tables.Appe nd tbl
    Set cat = Nothing

    End Sub
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Why using code, while you could just link a table to the excel sheet ?

    Nic;o)

    Comment

    Working...