你没有COPY模块的中的Out2Excel代码
临时查询是用代码生成的
Private Sub CreateQury()
Dim StrWhere As String
Dim Sql As String
Dim AQueryDef As DAO.QueryDef
'调用临时查询,为EXCEL的标题作准备
'如果不考虑标题,直接调用窗体的查询也行
Sql = "SELECT id as 序号,mingzi as 客户名字,danwei as 客户单位, leixing as 客户类型, dizhi as 客户地址, zdianhua as 联系电话, shouji as 手机, youxiang as 邮箱,hetongriqi as 合同签订日期,hetongjinge as 合同金额, dengjiriqi as 登记日期,hetonglianjie as 合同连接,hetongyuanwen as 合同原文, beizhu as 备注 FROM tblkehu"
If Len(FiltFrmWhere) > 0 Then
Sql = Sql & " where " & FiltFrmWhere
End If
CurrentDb.QueryDefs.Refresh
Set AQueryDef = CurrentDb.QueryDefs("临时查询")
AQueryDef.Sql = Sql
If (Err) Then
Exit Sub
End If
AQueryDef.Close
CurrentDb.QueryDefs.Refresh
End Sub