I'd like to use VBA to import an excel file to an Access table.
So far I have a form with a button, the button opens up a window to get the file. I assume I use the transferspreadsheet method, but I'm running into problems:
strFilter = ahtAddFilterItem(strFilter, "Microsoft Excel File (*.xls)", "*.xls")
strFile = ahtCommonFileOpenSave(InitialDir:=CurrentDb.Name,Filter:=strFilter, OpenFile:=True, DialogTitle:="Select location of Inventory data file to import")
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strSheetName, strFile
This is how TransferSpreadsheet is defined:
Sub TransferSpreadsheet([TransferType As AcDataTransferType = acImport], [SpreadsheetType As AcSpreadSheetType = acSpreadsheetTypeExcel97], [TableName], [FileName], [HasFieldNames], [Range], [UseOA])
so... where it says "TableName", is that the worksheet name I'm importing?... or, is that the Access table name I want to import to? Secondly, what is the "HasFieldNames"? And Third, the beginning of the file I wish to import has 3 blank rows (which I hear is not good for importing). How do I delete these rows from Access.
Characteristics of the excel file:
It has numerous columns that stay fixed, but the amount of records (rows) will vary from week to week.
any help is appreciated
modest
So far I have a form with a button, the button opens up a window to get the file. I assume I use the transferspreadsheet method, but I'm running into problems:
strFilter = ahtAddFilterItem(strFilter, "Microsoft Excel File (*.xls)", "*.xls")
strFile = ahtCommonFileOpenSave(InitialDir:=CurrentDb.Name,Filter:=strFilter, OpenFile:=True, DialogTitle:="Select location of Inventory data file to import")
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strSheetName, strFile
This is how TransferSpreadsheet is defined:
Sub TransferSpreadsheet([TransferType As AcDataTransferType = acImport], [SpreadsheetType As AcSpreadSheetType = acSpreadsheetTypeExcel97], [TableName], [FileName], [HasFieldNames], [Range], [UseOA])
so... where it says "TableName", is that the worksheet name I'm importing?... or, is that the Access table name I want to import to? Secondly, what is the "HasFieldNames"? And Third, the beginning of the file I wish to import has 3 blank rows (which I hear is not good for importing). How do I delete these rows from Access.
Characteristics of the excel file:
It has numerous columns that stay fixed, but the amount of records (rows) will vary from week to week.
any help is appreciated

modest