访问 - 报告打开,然后在关闭打开的表单时隐藏
我正在使用 Access 2003,并且有一个表单可以收集报告的一些过滤条件。输入标准后,用户单击“确定”按钮,然后使用以下 VBA 启动报告。
DoCmd.OpenReport "ReportName", acViewPreview
打开报告后,我发出以下命令来关闭收集过滤条件的表单...
Me.Close
表单关闭,但我想在前台保持打开状态的报告被隐藏。知道为什么会发生这种情况吗?
I am using Access 2003 and I have a form that collects some filtering criteria for the report. Once the criteria is entered the user clicks and "OK" button and the report is launched using the following VBA.
DoCmd.OpenReport "ReportName", acViewPreview
After the report is opened I issue the following command to close the form that collected the filtering criteria ...
Me.Close
The form closes however the report, which I wanted to stay open in the foreground, is hidden. Any idea why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当所有其他方法都失败且表单和报告在所需时间出现在前面时,您可以使用 DoCmd.SelectObject 明确执行此操作:
如果这不起作用,则涉及其他内容,例如使用 acDialog 开关打开的表单或报告,或者表单/报告的 Modal 或 Popup 属性设置为 True。
或者,可能有一个计时器在某处运行,导致发生一些吸引焦点的事情。
When all else fails with forms and reports coming to the front at the desired time, you can do it explicitly with DoCmd.SelectObject:
If that doesn't work, there's something else involved, like forms or reports opened with the acDialog switch, or with forms/reports having the Modal or Popup properties set to True.
Or, there might be a timer running somewhere that's causing something to happen that's grabbing focus.
尝试将“报告”属性“模态”设置为“是”(在“其他属性”中)。
Try setting the Report property Modal to Yes (in Other Properties).
关闭表单然后打开报告是否有效?我猜这与焦点在物体之间来回移动有关。
编辑
您的代码应该如下所示:
此外,正如其他人指出的那样,没有本机关闭函数。
Does closing the form, then opening the report work? I'm guessing it has to do with the focus being shifted back and forth between the objects.
EDIT
Your code should look something like this:
Also, there is no native close function as others have pointed out.
我为此苦苦挣扎了几天。看来您需要关闭当前窗口,然后在打印预览中打开报告。
我在报表中嵌入了数据透视图上的按钮。 (访问2010)
当我尝试打印报告时,数据透视图上的任何过滤都不会转移到“DoCmd.Printout”命令。
有人建议我使用打开打印预览窗口,但它从未获得焦点。我必须单击屏幕,然后返回打印预览窗口。下面的代码似乎可以纠正这个问题。
I struggled with this for a couple days. It seems you need to close the current window and then open the report in Print Preview.
I have a button on a pivotchart embedded in a Report. (Access2010)
When i tried to just print the report- any filtering on the pivot chart didn't get carried over to the "DoCmd.Printout" command.
It was suggested I use open the print preview window, but it never received focus. I had to click off screen then back toe the print preview window. The code below seems to correct this.