Access 2007 - 子报表过滤器更改的问题 [英] Access 2007 - Problem with subreport filter change

查看:91
本文介绍了Access 2007 - 子报表过滤器更改的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Access 2007(12.0.6535.5005)SP2 MSO(12.0.6554.5001)

我在未绑定的主报表上有一个子报表,我通过主报表逐步更改了 过滤器加载事件。

Using Access 2007 (12.0.6535.5005) SP2 MSO (12.0.6554.5001)
I have a subreport on an unbound main report that I progmatically change the filter via the main report on load event.

  If Weekday(Date) = 6 Then
    Me.[subreport_name].Report.Filter = "((([Issue-Tracker].Site)='Site 1') AND (([Issue-Tracker].[I-Type].Value)='Schedule') " & _
      "AND (([Issue-Tracker].[Scheduled Start])=Date()+3) AND (Not ([Issue-Tracker].[Issue Status])='Resolved'))"
  End If

如果我只是打开报告或运行报告视图,则此报告会完全按预期生成。 但是,如果我尝试生成打印预览,则相同的代码会导致运行时错误2101(对属性设置无效)。 由于我期望并了解Access 2007中的这种行为
,因此我很容易解决。 但是,不是其他人使用我的报告。 

This report generates exactly as expected if I just open the report or run report view.  However, if I try to generate a print preview, the same code causes a runtime error 2101 (setting invalid for property).  Since I expect and know this behavior from Access 2007, it's easy for me to work around.  But, it's not for the others who utilize my report. 

我的问题:

1.我能做些什么来纠正这种行为。  ; (注意:我添加了错误捕获并可以阻止错误消息,但如果用户尝试直接打印预览,则报告错误。但是,如果首先打开报告,然后将
切换为打印预览,报告是准确的。)

2.我是否可以逐步测试直接启动打印预览与从报表视图切换到打印预览?

My questions:
1. Is there something I can do to correct this behavior.  (Note: I have added error trapping and can prevent the error message, but the report is wrong if user attempts to go straight to print preview.  However, if the report is opened first and then switched to print preview, the report is accurate.)
2. Can I progmatically test direct launch to print preview vs. switch to print preview from report view?

谢谢帮助!

推荐答案

你可以在If Weekay(Date)= 6之后尝试Me.Requery和/或Me.Recalc作为第一行声明。我不知道为什么报告在一种模式下是准确的而不是另一种模式。这可能是因为报告没有任何约束力。只是一个猜测。
You might try a Me.Requery and/or Me.Recalc as a fist line after the If Weekay(Date)=6 Then statement. I don't know why a report would be accurate in one mode and not another. It could be because the report is not bound to anything. Just a guess.


这篇关于Access 2007 - 子报表过滤器更改的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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