访问 - 报告打开,然后在关闭打开的表单时隐藏

发布于 2024-09-28 08:02:45 字数 269 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

萌能量女王 2024-10-05 08:02:45

当所有其他方法都失败且表单和报告在所需时间出现在前面时,您可以使用 DoCmd.SelectObject 明确执行此操作:

  DoCmd.OpenReport "rptMyReport", acViewPreview
  DoCmd.SelectObject acReport, "rptMyReport"
  DoCmd.Close acForm, Me.Name

如果这不起作用,则涉及其他内容,例如使用 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:

  DoCmd.OpenReport "rptMyReport", acViewPreview
  DoCmd.SelectObject acReport, "rptMyReport"
  DoCmd.Close acForm, Me.Name

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.

最初的梦 2024-10-05 08:02:45

尝试将“报告”属性“模态”设置为“是”(在“其他属性”中)。

Try setting the Report property Modal to Yes (in Other Properties).

柳絮泡泡 2024-10-05 08:02:45

关闭表单然后打开报告是否有效?我猜这与焦点在物体之间来回移动有关。

编辑

您的代码应该如下所示:

Private Sub Command0_Click()

    'your code here

    DoCmd.Close acForm, Me.Name

    DoCmd.OpenReport "Report1", acViewPreview

End Sub

此外,正如其他人指出的那样,没有本机关闭函数。

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:

Private Sub Command0_Click()

    'your code here

    DoCmd.Close acForm, Me.Name

    DoCmd.OpenReport "Report1", acViewPreview

End Sub

Also, there is no native close function as others have pointed out.

枕头说它不想醒 2024-10-05 08:02:45

我为此苦苦挣扎了几天。看来您需要关闭当前窗口,然后在打印预览中打开报告。

我在报表中嵌入了数据透视图上的按钮。 (访问2010)
当我尝试打印报告时,数据透视图上的任何过滤都不会转移到“DoCmd.Printout”命令。

有人建议我使用打开打印预览窗口,但它从未获得焦点。我必须单击屏幕,然后返回打印预览窗口。下面的代码似乎可以纠正这个问题。

Private Sub Command1_Click()
DoCmd.Save
DoCmd.Close
DoCmd.OpenReport "R-MyReport", acViewPreview

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.

Private Sub Command1_Click()
DoCmd.Save
DoCmd.Close
DoCmd.OpenReport "R-MyReport", acViewPreview
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文