I have the following code but it isn't importing the excel sheets into the specified table:
Code was written to a module and then called to a button on my form. Unless I'm not doing something with my button, wondering if the code above is wrong? What should I be adding to my button.. I just wrote:
P.S. Fieldnames from access table and all excels are same.
Thanks.
Code:
Sub Import()
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
blnHasFieldNames = True
strPath = "C://Documents"
strTable = "tblCSV"
strFile = Dir(strPath & "*.xlsx")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, blnHasFieldNames
strFile = Dir()
Loop
End Sub
Code was written to a module and then called to a button on my form. Unless I'm not doing something with my button, wondering if the code above is wrong? What should I be adding to my button.. I just wrote:
Code:
Private Sub btnImport_Click()
Import
End Sub
P.S. Fieldnames from access table and all excels are same.
Thanks.