|
Dim qdf As DAO.QueryDef 'qdf被定义为一个查询定义对象
Dim strWhere, strSQL As String
strWhere = Me.匹配库存.Form.Filter
If strWhere = "" Then
'没有条件
strSQL = "SELECT * FROM 匹配库存"
Else
'有条件
strSQL = "SELECT * FROM 匹配库存 WHERE " & strWhere
End If
Set qdf = CurrentDb.QueryDefs("查询记录结果")
qdf.sql = strSQL
qdf.Close
Set qdf = Nothing
DoCmd.OutputTo acOutputQuery, "查询记录结果", acFormatXLS, , True
Exit_导出记录_Click:
Exit Sub
Err_导出记录_Click:
MsgBox Err.Description
Resume Exit_导出记录_Click
End Sub
另外您需要随便建立一个名叫“查询记录结果”的查询。 |
|