Good Afternoon All;
I have the following code in a module in my database:
This code works really well for importing data and creating 600 plus tables, however the problem is.... it imports fields that are blank. Is there a way to exclude data if the first field has no data within it?
So an example of this would be as follows:
Its worth pointing out that.. the 600 plus CSV files are new data given by a third party, and I do not know ID field names. This is why I would like to know if I can exclude data if I don't know the field names.
Thanks in advance
Tor Fey
I have the following code in a module in my database:
Code:
Function DoImport()
Dim strPathFile As String
Dim strFile As String
Dim strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
' Change this next line to True if the first row in CSV worksheet
' has field names
blnHasFieldNames = True
' Replace C:\Documents\ with the real path to the folder that
' contains the CSV files
strPath = "C:\ImportData"
' Replace tablename with the real name of the table into which
' the data are to be imported
strFile = Dir(strPath & "*.csv")
Do While Len(strFile) > 0
strTable = Left(strFile, Len(strFile) - 4)
strPathFile = strPath & strFile
DoCmd.TransferText acImportDelim, , strTable, strPathFile, blnHasFieldNames
' Uncomment out the next code step if you want to delete the
' EXCEL file after it's been imported
' Kill strPathFile
strFile = Dir()
Loop
End Function
This code works really well for importing data and creating 600 plus tables, however the problem is.... it imports fields that are blank. Is there a way to exclude data if the first field has no data within it?
So an example of this would be as follows:
Its worth pointing out that.. the 600 plus CSV files are new data given by a third party, and I do not know ID field names. This is why I would like to know if I can exclude data if I don't know the field names.
Thanks in advance
Tor Fey
Last edited: