|
Private Sub Command34_Click()
On Error GoTo Err_Command34_Click
Dim qdf As DAO.QueryDef 'qdf被定义为一个查询定义对象
Dim strWhere, strSQL As String
' strWhere = Me.CP.Form.Filter
' If strWhere = "" Then
'没有条件
' strSQL = "SELECT * FROM [CP]"
' Else
'有条件
' strSQL = "SELECT * FROM [CP] WHERE " & strWhere
' End If
strSQL = Me.CP.Form.RecordSource
Set qdf = CurrentDb.QueryDefs("CP2")
qdf.sql = strSQL
qdf.Close
Set qdf = Nothing
DoCmd.OutputTo acOutputQuery, "CP2", acFormatXLS, , True
Exit_Command34_Click:
Exit Sub
Err_Command34_Click:
MsgBox Err.Description
Resume Exit_Command34_Click
End Sub |
|