If IsNull(SortCriteria) Then
SortCriteria = "ID"
End If
SQL = SQL & " ORDER By " & SortCriteria
Dim db As DAO.Database
Dim qdf As QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("Form_SelectActionsQuery")
qdf.SQL = SQL
DoCmd.OpenQuery "Form_SelectActionsQuery"
MsgBox "Continue"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Form_SelectActionsQuery", "C:\RTM\TestExcelTransfer", True
MsgBox "All Done. Excel file Created"
DoCmd.Close acForm, "Form_SelectActionsQuery"
DoCmd.OpenForm "Actions"
在此代码上方,我创建了可以改变搜索条件的SQL。 一切都适用于后续运行,包括创建Excel文件BUT" Form_SelectActionsQuery"不会在屏幕上更新或刷新。 有人可以帮忙吗?