没有测试,你自己试试
把查询名字更改为 Q
Dim Qdf As DAO.QueryDef
Dim sSQL As String
Dim sWhere As String
Dim DateArray() As Date
Dim i As Integer
If IsNull(Me.日期2) Then
Exit Sub
End If
DateArray = Split(Me.日期2, ",")
For i = 0 To UBound(DateArray)
sWhere = sWhere & "#" & DateArray(i) & "#,"
Next
sSQL = "select * from 订单明细 where 打印日期 in (" & sWhere & ")"
Set Qdf = CurrentDb.QueryDefs("Q")
Qdf.SQL = sSQL
Qdf.Close
Set sqf = Nothing
DoCmd.OpenQuery "Q"