如何从弹出窗体中筛选报表 [英] How to Filter a Report from a Pop-Up Form

查看:44
本文介绍了如何从弹出窗体中筛选报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个弹出窗体,以便我的同伴可以通过4种类别轻松过滤信息:Presenter,Evaluator,Date或Topic。所有这些信息都存储在我的数据表中,我创建了一个名为rptEvaluation的报告。我单独在组合框中创建了一个带有这些Presenter,Evaluator等的表单。我的弹出框已经提供了报告和列出的所有搜索选项。我还添加了一个清除命令按钮,可以成功清除组合框中的数据。除了我的设置过滤器按钮,一切正常。我一直在模仿我找到的所有教程中的代码,但我仍然没有成功。这是我对''Set Filter''命令按钮的代码:


Private Sub Set_Filter_Click()

Dim strSQL As String,intCounter As Integer

''构建SQL字符串

对于intCounter = 1到4

如果我(过滤器& intCounter)<> ""然后

strSQL = strSQL& " [" &安培; Me(Filter& intCounter).Tag& , &安培; " = &安培; Chr(34)&我(过滤器& intCounter)& Chr(34)& "并且

结束如果

下一页


如果strSQL<> ""然后

''剥离最后一次'并且

strSQL =左(strSQL,(Len(strSQL) - 5))

''设置过滤属性

报告! [rptEvaluation] .filter = strSQL

报告![rptEvaluation] .FilterOn = True

Else

报告![rptEvaluation] .FilterOn = False

结束如果


结束子


当我尝试运行它时,我收到一条消息说要求我输入参数值。我不确定这意味着什么。


我确定这个问题已经得到解答但我仍然遇到困难。请帮助


谢谢

I''m trying to create a popup form so that my peers have and easy way to filter information by 4 categories: Presenter, Evaluator, Date, or Topic. All this information is stored in my Data table and I have created a report called rptEvaluation. Seperately I have created a form with these Presenter, Evaluator, etc in a combo box. I have gotten as far as my pop up box coming up with the report and all the search options listed. I have also included a ''Clear'' command button that successfully clears the data in the combo boxes. Everything works except for my ''Set Filter'' button. I''ve been mimicking the codes in all the tutorials I''ve found but I am still unseccessful. This is the code I have for the ''Set Filter'' command button:

Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
''Build SQL String
For intCounter = 1 To 4
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next

If strSQL <> "" Then
''Strip Last " And "
strSQL = Left(strSQL, (Len(strSQL) - 5))
''Set the Filter property
Reports![rptEvaluation].filter = strSQL
Reports![rptEvaluation].FilterOn = True
Else
Reports![rptEvaluation].FilterOn = False
End If

End Sub

When I try to run it I get a message saying asking me to enter a parameter value. I''m not sure what this means.

I''m sure this question has already been answered but I''m still having difficulty. Please help

thank you

推荐答案

您被提示输入什么变量作为参数值?
What variable are you being prompted to enter as a parameter value?



您提示输入哪个变量作为参数值?
What variable are you being prompted to enter as a parameter value?



我不知道......消息只是说输入参数值。在无知中我只是输入随机名称和数字来查看发生了什么,当然,我的报告显示空白

I have no idea..the message just says "enter parameter value". In ignorance I''ve just typed in random names and numbers to see what happens and of course, my report shows up blank


我几乎100%确定问题出在strSQL中。我认为我(过滤器& intCounter).Tag正在返回Null,所以你在strSQL中留下了[],这就是提示你输入参数的东西。要验证这一点,请在for循环后执行Debug.Print strSQL。这将显示您传递给过滤器的标准。


如果这确实是问题所在。如果您告诉我您在表单上使用的控件和字段,我可以帮助您正确构建过滤字符串。
I''m almost 100% sure the problem lies within strSQL. I think Me("Filter" & intCounter).Tag is returning Null so you''re left with [] within your strSQL which is what is prompting you to enter a parameter. To verify this do a Debug.Print strSQL after your for loop. This will show you what criteria you''re passing to the filter.

If this is indeed the problem. I can help you properly build the filter string if you tell me what controls and fields you are using on your form.


这篇关于如何从弹出窗体中筛选报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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