我目前有一个Access查询,可以将.csv文件导出到带有标题的目录。我需要获取日期列并获取MAX日期并通过VBA代码将其添加到Excel电子表格中。我将有10-20访问数据库,这样做。以下是导出VBA代码。
Option Compare Database
Option Explicit
Sub ExportQuery()
Dim PathName As String, FileName As String
PathName = Application.CurrentProject.Path & "\CsvFiles\"
FileName = Replace(Replace(CurrentProject.Name, "sharepoint_", ""), ".accdb", "")
DoCmd.TransferText acExportDelim, , "Qry_ExportToCsv", PathName & FileName & ".csv", HasFieldNames:=True
End Sub