将我的变量作为参数传递给MS Access函数

时间:2014-03-03 14:16:42

标签: ms-access parameters

是否可以仅将我的变量值传递给Access中的预先存在的方法? 例如,outputTo命令看起来像这个

DoCmd.OutputTo acOutputReport, "rptName", acFormatSNP, strAttachmentPath

strAttachmentPath工作正常,我把它声明为strAttachmentPath =“C:...)

当我使用变量来声明格式时,这只是一个问题:

DoCmd.OutputTo acOutputReport, "rptName", varFormat, strAttachmentPath

当我声明varFormat =“acFormatSNP”时,我收到错误'编译错误:无效的限定符'。

为什么这不起作用?

我想要的原因是能够检查正在运行的访问版本。如果它是2003使用acFormatSNP,如果它是任何其他使用acFormatPDF

1 个答案:

答案 0 :(得分:1)

你需要使用acFormatSNP的内容,它是一个内置的常量,所以:

Dim stype as Text
stype = "Snapshot Format (*.snp)"
''Or, no quotes
stype = acFormatSNP 
DoCmd.OutputTo acOutputReport, "table1", stype, "z:\docs\test.snp"