如何使用基于fieldname的文件名将Access报告保存到pdf [英] How to save an Access report to pdf with filename based on fieldname

查看:142
本文介绍了如何使用基于fieldname的文件名将Access报告保存到pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨Evereyone,


我正在寻求帮助,我一定会在这里找到它; o)


我已创建访问简单数据库以获取报告。通过组合框,我选择一个客户编号,点击一个按钮,然后会出现特定的报告。

我能够将每个报告手动保存到pdf文件并为其命名,但我想要它自动完成

。最重要的是文件名必须是客户名称和代码出现在报告上。


我找到了一些解决方案,但没有在实践中工作。


我的数据库由以下部分组成:

- 基于2个excell文件的名为QryHyperion的查询

o构成数据库的字段:

  • Hyperion
  • 姓名
  • SAP
  • 其他一些人(不重要提及)
  • Hi Evereyone,

    I’m looking for some help and I’m sure to find it here ;o)

    I’ve created in access a simple database to obtain reports. Via a combobox I select a customer number, click on a button and the specific report appears.
    I’m able to save manually each report to a pdf file and give it a name, but I want it to be
    automatically done. The most important is that filename must be “customer name” and “code” appearing on the report.

    I’ve found some solutions but not working in practice.

    My DB is composed of:
    - A query named “QryHyperion” based on 2 excell files
    o Fields composing the DB:

    • Hyperion
    • Name
    • SAP
    • Some others(not important to be mentioned)
    • 展开 | 选择 | Wr ap | 行号

      推荐答案

      乍一看,我猜测你运行代码的地方可能无法访问字段[Name]和[Hypérion]。


      您是从表单模块还是单独的模块运行代码?


      如果从表单中,表单记录源是否包括[Name]和[Hyperion]?


      如果有,请试试这个。


      首先,名称是访问中的保留字,使用它作为字段名称可能会让您感到悲伤,并且在很多情况下可能会以非感性的方式悲伤。例如,引用Form.Name是表单底层记录集中的字段名称,还是表单名称?

      如果你坚持保持名为Name的字段,那么对表单绑定有一个控件到该字段,但请确保控件名称为其他名称,例如tb_Name(TextBox名称)。然后你可以使用:
      At at first glance, im guessing that the place where you run the code might not have access to the fields [Name] and [Hypérion].

      Are you running the code from a form module, or a seperate module?

      And if from a form, does the forms recordsource include [Name] and [Hyperion]?

      If they do, try this.

      First, Name is reserved word in access, and using that as a field name will likely cause you grief, and in alot of cases probably grief in a non-sensical way. For example to refer to Form.Name is that the field name in the forms underlying recordset, or the forms name?
      If you insist on keeping the field named Name, then have a control on the form bound to the field, but make sure the control is named something else, for example tb_Name (TextBox name). Then you could use:
      展开 | 选择 | Wrap | 行号


      您收到错误消息了吗?如果是这样,你能提供吗?您确定您对要导出文件的文件夹有权限吗?


      您是否尝试删除 myPath + strReportName 参数DoCmd.OutputTo总是看看Access是否提示您命名文件?


      此外,您可能想要为完整路径创建另一个变量并将路径连接到报告名称而不是在DoCmd中这样做。


      希望这有帮助,

      beacon
      Are you receiving an error message? If so, can you provide it? Are you sure you have permissions to the folder where you''re trying to export the file?

      Have you tried removing the myPath + strReportName argument in the DoCmd.OutputTo altogether to see if Access prompts you to name the file?

      Also, you may want to create another variable for the full path and concatenate the path to the report name there instead of doing so in the DoCmd.

      Hope this helps,
      beacon


      你正在使用+连接的字符,这是不可靠的,因为如果它加入的值的 是空的,则返回Null值(参见在WHERE子句中使用&"和+作为完整说明)。


      如果您使用&然后你至少会看到缺少的字符:
      You''re using the + character for concatenation, which is unreliable as it returns a value of Null if either of the values it joins is Null (See Using "&" and "+" in WHERE Clause for a full explanation).

      If you use the & character instead then you will at least see what is missing :
      展开 | 选择 | Wrap | 行号


      这篇关于如何使用基于fieldname的文件名将Access报告保存到pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆