Dim rst As Recordset
DoCmd.SetWarnings False
Set FS_Write = CreateObject("Scripting.FileSystemObject")
Set FS_Read = CreateObject("Scripting.FileSystemObject")
Set rst = CurrentDb.OpenRecordset("SELECT * FROM files")
Do While Not rst.EOF
file_name = rst.Fields("file_name")
DoCmd.RunSQL ("DELETE FROM " & file_name)
Set a2 = FS_Write.CreateTextFile("C:\rawae_f18\" & file_name & ".TXT", True)
For p_year = 2550 To 2553
Set a1 = FS_Read.OpenTextFile("C:\rawae_f18\" & p_year & "\" & file_name & ".TXT")
Do Until a1.AtEndOfStream
sText = a1.ReadLine
a2.writeline (sText)
Loop
a1.Close
Next p_year
a2.Close
rst.MoveNext
Loop
End Sub
ไม่มีความคิดเห็น:
แสดงความคิดเห็น