Private Sub cmd导出_Click()
On Error GoTo Err_cmd导出_Click
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