access的outputto函数

756次阅读
没有评论

共计 798 个字符,预计需要花费 2 分钟才能阅读完成。

提醒:本文最后更新于 2019-05-12 20:02,文中所关联的信息可能已发生改变,请知悉!

outputout 命令

Docmd.OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile,Encoding)

ObjectType  被输出对象的类型(表、查询还是窗体等……)

expression     必需。返回 DoCmd 对象的表达式。

acOutputForm
acOutputFunction
acOutputModule
acOutputQuery
acOutputReport
acOutputServerView
acOutputStoredProcedure
acOutputTable
acFormatASP
acFormatDAP
acFormatHTML
acFormatIIS
acFormatRTF
acFormatSNP
acFormatTXT
acFormatXLS
 
如果想导出成 97-2003 格式用 acSpreadsheetTypeExcel9
OutputFile  要输出文件的路径和完整名称。如果将该参数留空,Access 将提示指定输出文件名
AutoStart 逻辑值 ture or false,导出时是否启动程序。例如,导出成 xls 时,是否启动 excel。
TemplateFile 调用模版的路径和完整的名称。
需要注意的是导出时如果取消,ACCESS 会报错,所以代码中需要加一段出错处理,一般这种错误的代码是 2501.
示例:
Private Sub Command_Click()
 On Error GoTo err_Command_Click

DoCmd.OutputTo

acOutputTable,“Employees”,acFormatRTF,“D:\Employee.rtf”, True
err_Command_Click:

If Err.Number = 2501 Then Cancel = True

Exit Sub
正文完
 0
水东柳
版权声明:本站原创文章,由 水东柳 2019-01-24发表,共计798字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)