|
Private Sub Command2_Click()
Dim mypath As String
Dim Fso As Object
Dim myFile As Object
Dim mySQL As String
mypath = "D:\TanosSMax\TanosSMax\APT\2021-12\2021-12-23"
Set Fso = CreateObject("Scripting.FileSystemObject")
For Each myFile In Fso.getfolder(mypath).Files '遍历文件
If Fso.GetExtensionName(myFile) = "txt" Then '判断拓展名
mySQL = "INSERT INTO APTtest(路径,文件名,文件名1) VALUES('" & mypath & "' ,'" & myFile.Name & "','" & myFile.Name & "') " '插入路径和文件名的SQL语句
DoCmd.SetWarnings WarningsOff '关闭提示
DoCmd.RunSQL mySQL '写入记录
DoCmd.SetWarnings WarningsOn '开启提示
End If
Next myFile
Set Fso = Nothing
DoCmd.OpenQuery "替换txt"
Me.testAPTinfo子窗体.Requery
End Sub |
|
|