1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Sub OpenTextFileTest()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Dim sSQL As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("C:\Documents and Settings\MB\BUREAU\BDD\ID_sations.txt", ForReading, TristateFalse)
Do While Not f.AtEndOfStream
NOM = f.ReadLine()
MsgBox (NOM)
NOMtxt = NOM & ".txt"
'sql = "SELECT Id_Station, Date, Valeur FROM Cotes WHERE Id_Station='" & NOM & "'"
'Dim sql As String
'sSQL = "SELECT Id_Station, Date, Valeur FROM Cotes WHERE Id_Station = 2603100105 "
'Set rst = db.OpenRecordset(sSQL, dbOpenTable)
'CurrentDb.CreateQueryDef "sSQL", "SELECT Cotes.Id_Station, Cotes.Date, cotes.Valeur FROM Cotes WHERE Cotes.Id_Station = 2603100105"
CurrentDb.CreateQueryDef "sSQL", "SELECT Cotes.Id_Station, Cotes.Date, Cotes.Valeur FROM Cotes WHERE Cotes.Id_Station = '" & NOM & "'"
DoCmd.OpenQuery "sSQL"
Open "C:\Documents and Settings\MB\BUREAU\BDD\schema.ini" For Output As #1
Print #1, "["; NOMtxt; "]", "CharacterSet = ANSI", "Format=TabDelimited", "ColNameHeader = False", "Format=Delimited(;)", Chr(13), "DECIMALSYMBOL=."
Close #1
DoCmd.TransferText acExportDelim, , "sSQL", "C:\Documents and Settings\MB\BUREAU\BDD\" & NOMtxt
Kill "C:\Documents and Settings\MB\BUREAU\BDD\schema.ini"
DoCmd.RunSQL ("DROP TABLE sSQL")
DoCmd.Close
Loop
f.Close
End Sub |
Partager