Currently, I'm doing a simple OutputTo statement in VBA to export query results to an Excel file and I'm appending today's date to the output file name.
Private Sub Command1_Click()
Dim TodaysDate As String
TodaysDate = Format(DateSerial(Year(Date), Month(Date), Day(Date)), "mm-dd-yy")
DoCmd.OutputTo acOutputQuery, "FQ DAILY 7366 REPORT FUND 3801", "ExcelWorkbook(*.xlsx)", "I:\fullservice\Common\Amy's Group\REITs\FS Investments\3801(R12749 and R07366)\R07366\FQ 7366 Daily 3801 (" & TodaysDate & ").xlsx", False, "I:\fullservice\Common\Amy's Group\REITs\FS Investments\Template Files\FQ 7366 Daily 3801.xlsx", , acExportQualityPrint
DoCmd.Beep
MsgBox "Spreadsheet Transferred Successfully", vbOKOnly, "Transfer Results"
End Sub
However, what I really need is the prior business date appended to the file name instead of today's date. I have a ODBC table available to me that contains this date, but I don't know how to extract that date to then use it as part of the exported file name.
Please help...
Thanks!
Mike
Private Sub Command1_Click()
Dim TodaysDate As String
TodaysDate = Format(DateSerial(Year(Date), Month(Date), Day(Date)), "mm-dd-yy")
DoCmd.OutputTo acOutputQuery, "FQ DAILY 7366 REPORT FUND 3801", "ExcelWorkbook(*.xlsx)", "I:\fullservice\Common\Amy's Group\REITs\FS Investments\3801(R12749 and R07366)\R07366\FQ 7366 Daily 3801 (" & TodaysDate & ").xlsx", False, "I:\fullservice\Common\Amy's Group\REITs\FS Investments\Template Files\FQ 7366 Daily 3801.xlsx", , acExportQualityPrint
DoCmd.Beep
MsgBox "Spreadsheet Transferred Successfully", vbOKOnly, "Transfer Results"
End Sub
However, what I really need is the prior business date appended to the file name instead of today's date. I have a ODBC table available to me that contains this date, but I don't know how to extract that date to then use it as part of the exported file name.
Please help...
Thanks!
Mike