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?
Expand|Select|Wrap|Line Numbers
- 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