注册 登录
Office中国论坛/Access中国论坛 返回首页

todaynew的个人空间 http://www.office-cn.net/?144436 [收藏] [复制] [分享] [RSS]

日志

导出Excel函数

热度 1已有 1007 次阅读2009-3-9 13:42 |个人分类:习作|

'导出Excel函数

'Qname--查询名称

'Pfrmane--父窗体名称

'Ctlname--子窗体控件名称

'n--n=1按子窗体,n=2按子窗体数据源查询

Public Function myoutE(Qname As String, Pfrmname As String, Ctlname As String, n As Long)

Dim myform As Form

Dim Qdef As QueryDef

Dim strSQL As String

Dim myformname As String

Set myform = Forms(Pfrmname).Controls(Ctlname).Form

myformname = myform.Name

SQLstr = myform.Form.RecordSource

SQLstr = "select * from " & SQLstr

Set Qdef = CurrentDb.QueryDefs(Qname)

Qdef.sql = SQLstr

Select Case n

          Case 1

                  DoCmd.OutputTo acOutputForm, myformname, acFormatXLS, CurrentProject.Path & "导出表.xls", True

          Case 2

                  DoCmd.OutputTo acOutputQuery, Qanme, acFormatXLS, CurrentProject.Path & "导出表.xls", True

End Select

Qdef.Close

Set Qdef = Nothing

End Function

 

刚表态过的朋友 (0 人)

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-13 03:46 , Processed in 0.062681 second(s), 17 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部