|
Private Sub cmd导出_Click()
On Error GoTo Err_cmd导出_Click
'刘小军(Alex) 2003-5-22
'这里将使用DAO来改变查询的SQL语句,必须先在“工具”→“引用”中选择
'Microsoft DAO 3.6 Object Library.
'================================
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_cmd导出_Click:
Exit Sub
Err_cmd导出_Click:
MsgBox Err.Description
Resume Exit_cmd导出_Click
End Sub |
|