I have put this code together (from various posts on the web and the help file...)
It loops through a folder of CSVs and imports them into a table, updating a column with the file name. What I am stuck with is that it asks me Yes or No do I want to update the records for the update part. Anyway I can get it to just answer yes?
Thanks!!!
misscrf
It is never too late to become what you could have been ~ George Eliot
It loops through a folder of CSVs and imports them into a table, updating a column with the file name. What I am stuck with is that it asks me Yes or No do I want to update the records for the update part. Anyway I can get it to just answer yes?
Code:
Private Sub Command0_Click()
Dim strDocPath As String
Dim strCurrentFile As String
strDocPath = "O:\ProjectShare\123456 Project\test\"
strCurrentFile = Dir(strDocPath & "*.csv")
Do Until strCurrentFile = ""
DoCmd.TransferText acImportDelim, "myspecs", "tblCSV", strDocPath & strCurrentFile, -1
DoCmd.RunSQL "UPDATE tblCSV SET tblCSV.FileName = """ & strCurrentFile & """ WHERE tblCSV.FileName Is Null"
strCurrentFile = Dir
Loop
End Sub
Thanks!!!
misscrf
It is never too late to become what you could have been ~ George Eliot