By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,962 Members | 2,545 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,962 IT Pros & Developers. It's quick & easy.

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

P: 46
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.

Sub CreateTable_forTP_Table()

Dim rstSubjectProp, rstMarkerScore, rstStatistics, rstEpochbEpoch, rstAnalysisInput As Recordset
'subject properties table
Dim SubjectID As String ' Identity
Dim Initials As String
Dim Gender As String
Dim Age As Integer
Dim AgeExportCreation 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\StatisticsTable.xlsx"

On Error Resume Next
Kill New_TablePath
On Error GoTo 0

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

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

cat.tables.Append tbl
Set cat = Nothing

End Sub
Dec 11 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,072
Why using code, while you could just link a table to the excel sheet ?

Dec 11 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.