访问报告 - 奇怪的结果 [英] Access Report - Weird Result

查看:34
本文介绍了访问报告 - 奇怪的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向大家致意,


我在MS Access 2003中有一个报告,在打印预览模式下看起来很好。当我单击打印按钮时,第一个页脚中打印输出的数据会发生变化。有些值与预览有相同的最后几位,但前面的数字不同,有些是完全不同的。


我知道如果没有看到结果和报告,这可能很难回答代码(它为页脚做了一些选择性的累积),但是之前有人见过这样的东西吗?如果是这样,问题是什么?


谢谢,

Zwoker。

Greetings everyone,

I have a report in MS Access 2003 that looks fine in print preview mode. When I click the print button the data on the printed output, in the first footer changes. Some of the values have the same last few digits as the preview but different preceding digits, some are completely different.

I know this is probably hard to answer without seeing the result and the report code (which does some selective accumulating for the footer), but has anyone seen anything like this before? And if so, what is the problem?


Thanks,
Zwoker.

推荐答案

嗨Zwoker。如您所知,在没有看到报告输出或涉及的页脚代码的情况下确实难以推测这一点。


如果您使用On Format和On Print方法,则需要注意,对于报告的任何一个部分,可以多次调用这些方法。可能性是在打印预览和实际打印模式之间对这些事件的调用次数不同。


如果您的代码没有正确处理对这些事件的多次调用,您可能会在没有意识到的情况下设置和累积错误的值。您可以测试PrintCount和FormatCount值,以确保正确处理多个调用。顺便说一句,多个调用是常态 - 当部分从一个页面移动到另一个页面并且页面重新格式化时,您可以期望在On Print发生之前触发许多格式事件。


另一种可能性是变量没有被适当地初始化,因此伪数据被添加到累加器。不过我只是猜测。


听起来你必须非常清楚你想要实现的逻辑。如果使用事件代码设置累加器值,则必须采用非常系统的方法进行调试。


-Stewart
Hi Zwoker. As you know it is indeed difficult to speculate on this without seeing the report output or the footer code involved.

If you are using the On Format and On Print methods you need to be aware that these can be called many times for any one section of your report. A possibility is that the number of calls to these events is different between the print preview and actual print modes.

If your code does not correctly handle multiple calls to these events you could be setting and accumulating values in error without realising it. You can test the PrintCount and FormatCount values to ensure that multiple calls are dealt with correctly. By the way, multiple calls are the norm - as sections are moved around from one page to another and the page reformatted you can expect many format events to be fired before On Print occurs.

Another possibility is that the variables are not being initialised appropriately, and consequently spurious data is being added to the accumulators. Just speculation on my part, though.

Sounds like you will have to be very clear about the logic of what you are trying to achieve. You will have to adopt very systematic approaches to debugging if you are using event code to set your accumulator values.

-Stewart


Hi Stewart,


感谢您的回复。


我在这些事件中的选择性累积代码已经处于PrintCount = 1的状态并且我已经设置好了初始化我的累积值。处理的开始和结束都是?如果单击打印按钮时MS Access没有初始化。


如果初始打印预览结果错误,我会寻找一个简单的编码错误。但这是正确的,因为数据的导出。这只是物理印刷品产生的不同和错误的东西。


我发现这个问题最困难的是它不会让我单步执行代码当它打印时 - 它只是忽略了任何断点等......我有。


我已经决定从报告中取出选择性积累的代码并将其放入进入首先提取数据的VBA代码。它可以做同样的工作,只生成报告的最终摘要数据。


我仍​​然想知道发生了什么,但我想现在我永远不会。


问候,

Zwoker。
Hi Stewart,

Thanks for the response.

My selective accumulation code in those events is already in a condition of PrintCount=1 and I have set up initialisation for my accumulated values. Both at the beginning and end of the processing ? in case MS Access doesn''t initialise when you click the print button.

If the initial Print Preview result was wrong I''d be looking for a simple coding error. But it is correct, as is an export of the data. It''s just the physical print that produces something different, and wrong.

I''m finding the hardest thing for this issue is that it will not let me step through the code when it prints - it just does it ignoring any breakpoints etc... that I have.

I have decided to take the code out of the report that does the selective accumulation and put it into the VBA code that extracts the data in the first place. It can do the same work and just produce the final summary data for reporting.

I''d still love to know what''s going on, but I guess now I never will.


Regards,
Zwoker.


嗨Zwoker。不要放弃这个 - 如果你不能破坏你的代码,那么有些不对劲。作为测试,我在报告的详细信息部分的On Print代码中设置了一个断点,VBA正常停止,允许所有常见的步骤,变量比较等。您可能认为不可能的一种可能性是,如果VBE等没问题,那么断点代码根本就没有被调用(驻留在未被格式化或打印的报告部分中,比方说?)。


如果需要有人要查看你的代码以获得第二意见,请随意压缩数据库的清理版本并将其附加到新帖子,或者如果您不希望发布公开副本,请将PM发送给我,我很乐意提供你的电子邮件地址。


干杯


斯图尔特
Hi Zwoker. Don''t give up on this one - something is amiss if you are unable to breakpoint your code. As a test I set a breakpoint in the On Print code of the detail section of a report and VBA stopped as normal, allowing all the usual stepthroughs, variable comparisons etc. A possibility, which you may think just cannot be so, is that if the VBE etc are OK then the breakpoint code is not being called at all (residing in a section of the report that is not being formatted or printed, say?).

If you need someone to look at your code for a second opinion feel free to zip a sanitised version of your DB and attach it to a new post, or if you do not wish to post a public copy send me a PM and I would be happy to supply you my e-mail address accordingly.

Cheers

Stewart


这篇关于访问报告 - 奇怪的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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