を使用して、Excelのエクスポートに簡単なアクセスを実行しようとしていますTransferSpreadsheet
。
Public Function Test()
Dim table_to_export As String
Dim excel_file_name As String
Dim has_header As Boolean
'Name of the Access table to export:
table_to_export = "AttendanceLogs"
'Path of the file to put data in. Update with your own path:
excel_file_name = "F:\Test\Att.xlsx"
'Export headers with data:
has_header = True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, table_to_export, excel_file_name
End Function
エクスポートは正常に機能していますAttendanceDate
。テーブルには列があります。
日付列に基づいてテーブルにフィルターを追加し(昨日のレコードのみをフィルター処理)、Excelにエクスポートする方法はありますか?
クエリを作成します。
Select * From AttendanceLogs Where AttendanceDate = DateAdd("d", -1, Date())
たとえば、AttendanceLogsYesterdayとして保存します。
次に、コードを調整します。
Dim query_to_export As String
' Name of the Access query to export:
query_to_export = "AttendanceLogsYesterday"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, query_to_export, excel_file_name
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加