I'm trying to create a table from Excel data that I am importing to Access. The first thing I want to make sure is that I am able to create a table and later populate it. But I am having no luck creating the table. Can any one be of soem help:
Public Sub AddFields()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim tdfNew As TableDef
Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet
Dim iRow As Integer
Dim strField As String
Dim strFieldType As String
'--- set a reference to Excel
Set objXL = New Excel.Application
'--- open the workbook
'Set objWkb = objXL.Workbooks.Open("C:\temp\Data to 12-31-2004.xls")
Set objWkb = objXL.Workbooks.Open(filenameinput.Value)
'--- set a reference to the correct worksheet
Set objSht = objWkb.Worksheets("Data")
'current database
Set db = CurrentDb
Set tdfNew = db.CreateTableDef("Table")
Set db = Nothing
Set rs = Nothing
Set tdfNew = Nothing
End Sub
Public Sub AddFields()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim tdfNew As TableDef
Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet
Dim iRow As Integer
Dim strField As String
Dim strFieldType As String
'--- set a reference to Excel
Set objXL = New Excel.Application
'--- open the workbook
'Set objWkb = objXL.Workbooks.Open("C:\temp\Data to 12-31-2004.xls")
Set objWkb = objXL.Workbooks.Open(filenameinput.Value)
'--- set a reference to the correct worksheet
Set objSht = objWkb.Worksheets("Data")
'current database
Set db = CurrentDb
Set tdfNew = db.CreateTableDef("Table")
Set db = Nothing
Set rs = Nothing
Set tdfNew = Nothing
End Sub