I need to import a text file into an Access table, but using import conditions in TXT file.
Below is my VBA code. It works only when you do not use the WHERE clause, because it is asking for parameter entry. I think the problem is in the missing field format specification.
Which adjustments do you recommend? Any suggestions would be appreciated.
TEXT FILE - Teste.txt
1;24;433;43;5
2;436;424;43;24
3;5454;656;656;555
4;545;545;0;0
5;65465;756;0;0
My Code VBA Access:
Sub MyTableImport()
Dim sqlStr As String
sqlStr = "SELECT * INTO NewTable "
sqlStr = sqlStr & " FROM [Text;HDR=Yes;FMT=Delimited;Database=C:\Temp].Teste.txt "
sqlStr = sqlStr & " WHERE field4 <> '0' AND field5 <> '0';"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlStr
DoCmd.SetWarnings True
End Sub

DELETE * FROM NewTable WHERE field4 = '0' OR field5 = '0'after the import.codeDim sqlStr As String Dim db As DAO.Database db.Execute sqlStr, dbFailOnError db.Close`