1 引用dao
2 随便做个查询,A
3 将str升为模块级变量
Private Sub Command38_Click()
Dim Qdf As DAO.QueryDef
Dim strSQL As String
Set Qdf = CurrentDb.QueryDefs("A")
If str = "" Then
strSQL = "select 供应商,货名,单价,折合包装 from 采购"
Else
strSQL = "select 供应商,货名,单价,折合包装 from 采购 where " & str
End If
Qdf.SQL = strSQL
Qdf.Close
Set Qdf = Nothing
DoCmd.OutputTo acOutputQuery, "A", acFormatXLS, CurrentProject.Path & "\A.xls", True
End Sub
原帖由 Henry D. Sy 于 2008-12-23 09:14 发表
1 引用dao
2 随便做个查询,A
3 将str升为模块级变量
Private Sub Command38_Click()
Dim Qdf As DAO.QueryDef
Dim strSQL As String
Set Qdf = CurrentDb.QueryDefs("A")
If str = "" Then
...
首先,引用了“Microsoft DAO 3.6 Object Library”(windows xp sp3+office xp)
然后,在当前文件夹新建了“A.xls”
最后,运行程序,但是,出现错误,错误如下图: