在报表中选择子报表 [英] Choosing between subreports in a report

查看:48
本文介绍了在报表中选择子报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个报告,在两个地方(43a和43b)我需要插入三个子报告中的一个,具体取决于谁付钱。我在Current事件中使用了以下代码:

Private Sub Report_Current()


如果Queries.qry_LOI。[Who_pays] =" B"然后

Set Me。[subrpt_43a_BothPay] .Visible = True:

Set Me。[subrpt_43a_PilgrimPays] .Visible = False:

Set Me。 [subrpt_43a_SponsorPays] .Visible = False:

Set Me。[subrpt_43b_BothPay] .Visible = True:

Set Me。[subrpt_43b_PilgrimPays] .Visible = False:

Set Me。[subrpt_43b_SponsorPays] .Visible = False

ElseIf Queries.qry_LOI。[Who_pays] =" S"然后

Set Me。[subrpt_43a_BothPay] .Visible = False:

Set Me。[subrpt_43a_PilgrimPays] .Visible = False:

Set Me。 [subrpt_43a_SponsorPays] .Visible = True:

Set Me。[subrpt_43b_BothPay] .Visible = False:

Set Me。[subrpt_43b_PilgrimPays] .Visible = False:

Set Me。[subrpt_43b_SponsorPays] .Visible = True

Else

Set Me。[subrpt_43a_BothPay] .Visible = False:

设置我。[subrpt_43a_PilgrimPays] .Visible = True:

Set Me。[subrpt_43a_SponsorPays] .Visible = False:

Set Me。[subrpt_43b_BothPay] .Visible = False:

Set Me。[subrpt_43b_PilgrimPays] .Visible = True:

Set Me。[subrpt_43b_SponsorPays] .Visible = False

结束如果


结束子


然而它不起作用。如果我在报表视图中向下滚动子报表都保持可见,但如果我向下翻页,我会在单词Visible上收到VBA编译错误,说无效使用属性。


任何人都可以看到我做错了吗?

I have a report where in two places (43a and 43b) I need to insert one of three subreports, depending on who is paying. I used the following code in the Current event:
Private Sub Report_Current()

If Queries.qry_LOI.[Who_pays] = "B" Then
Set Me.[subrpt_43a_BothPay].Visible = True:
Set Me.[subrpt_43a_PilgrimPays].Visible = False:
Set Me.[subrpt_43a_SponsorPays].Visible = False:
Set Me.[subrpt_43b_BothPay].Visible = True:
Set Me.[subrpt_43b_PilgrimPays].Visible = False:
Set Me.[subrpt_43b_SponsorPays].Visible = False
ElseIf Queries.qry_LOI.[Who_pays] = "S" Then
Set Me.[subrpt_43a_BothPay].Visible = False:
Set Me.[subrpt_43a_PilgrimPays].Visible = False:
Set Me.[subrpt_43a_SponsorPays].Visible = True:
Set Me.[subrpt_43b_BothPay].Visible = False:
Set Me.[subrpt_43b_PilgrimPays].Visible = False:
Set Me.[subrpt_43b_SponsorPays].Visible = True
Else
Set Me.[subrpt_43a_BothPay].Visible = False:
Set Me.[subrpt_43a_PilgrimPays].Visible = True:
Set Me.[subrpt_43a_SponsorPays].Visible = False:
Set Me.[subrpt_43b_BothPay].Visible = False:
Set Me.[subrpt_43b_PilgrimPays].Visible = True:
Set Me.[subrpt_43b_SponsorPays].Visible = False
End If

End Sub

However it doesn''t work. If I scroll down in report view the subreports all stay visible, but if I page down I get a VBA compile error on the word "Visible", saying "Invalid use of property".

Can anyone see what I''m doing wrong?

推荐答案

我发现报告中的事件不像他们在表格中那样工作。我猜测如果你在代码中的某处放置一个断点,你会发现它在报表视图中打开它时不会运行。尝试在打印预览中打开它,看看它是否有效。另外,尝试将代码移动到On_Load事件。
I find that events in reports don''t work the way that they do in forms. I''m guessing that if you put a break point somewhere in your code, you will find that it doesn''t run when you open it in Report View. Try opening it in Print Preview and see if it works. Also, try moving your code to the On_Load event.


谢谢Seth,但我遇到的问题是当它到达指定的事件时(不管它是否是'当前或负载)它得到编译错误无效使用属性首次出现的单词Visible突出显示。有谁知道那个消息的含义是什么?


我尝试用Let语句替换Set语句,但这只是给出错误424,需要对象。如果我将它们保留为Set语句但替换Me,则会发生同样的事情。与我一起!。不幸的是,我无法通过对象需要来找出它们的含义。
Thank you, Seth, but the problem I am having is that when it gets to the specified event (irrespective of whether it''s Current or Load) it gets a compile error "Invalid use of property" with the first occurrence of the word "Visible" highlighted. Does anyone know what that message means?

I tried replacing the Set statements with Let statements, but that just gives error 424, "Object required". The same thing happens if I leave them as Set statements but replace the Me. with Me!. Unfortunately I can''t find out what they mean by "object required", either.


这纯粹是猜测,但子报告只是主报告的控件(如是一个文本框或标签)。


所以你不需要任何套装。或者让我们


这种事情应该没问题:

This is purely a guess, but a subreport is just a control on the main report (as is a text box or label).

So you don''t need any "Sets" or "Lets"

This sort of thing should be fine:

展开 | 选择 | 换行 | 行号


这篇关于在报表中选择子报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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