如何将多个变量发送到查询驱动的报表 [英] How to send multiple variables to a query driven report

查看:49
本文介绍了如何将多个变量发送到查询驱动的报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我刚开始做重型Access编程(不是选择)而且我遇到了公司使用的报告问题。

有一些案例员工希望仅打印已检查打印标志的注释(附加到客户编号)。另一方面,他们希望打印附加到客户的所有评论。他们有两组报告这样做,我想知道是否有可能传递一个包含两个......呃......标准(?)的标准字符串。

这就是我现在设置的方法:

表单上有两个按钮,一个名为cmdPrintCurrentComments,另一个是cmdPrintComments,

第一个按钮,是打印所有客户评论看起来像这样并且工作正常:
私有子cmdPrintComments_Click()
错误GoTo Err_cmdPrintComments_Click

Dim stDocName As String
Dim stLinkCriteria As String
< br> stDocName =" CustomerReport"

stLinkCriteria =" [Order Number] ='" &安培;我![订单号]& "''"

DoCmd.OpenReport stDocName,acPreview,stLinkCriteria

Exit_cmdPrintComments_Click:
Exit Sub

Err_cmdPrintComments_Click:
MsgBox" frmViewComments中出现错误:cmdPrintComments_Click" ; &安培; vbcrlf& "错误描述:" &安培; Err.Description& vbcrlf& "错误号码:" &安培; err.Number
恢复Exit_cmdPrintComments_Click
End Sub


这是第二个按钮,它不能像它在这里实现的那样工作
Private Sub cmdPrintCurrentComments_Click()
On Error GoTo Err_cmdPrintCurrentComments_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName =" CustomerReport"

stLinkCriteria =" [OrderNumber] ='" &安培;我![订单号]& &'; And(Comments.PrintFlag)= Yes"
DoCmd.OpenReport stDocName,acPreview,stLinkCriteria

Exit_cmdPrintCurrentComments_Click:
Exit Sub

Err_cmdPrintCurrentComments_Click:
MsgBox" ; frmViewComments中出现错误:cmdPrintCurrentComments_Click" &安培; vbcrlf& "错误描述:" &安培; Err.Description& vbcrlf& "错误号码:" &安培; err.Number
恢复Exit_cmdPrintCurrentComments_Click
End Sub


当我尝试触发事件时,它要求使用Comments.PrintFlag,它应该是一个参数然后如果你输入是的话在报告中没有显示任何评论。

任何想法都会受到高度赞赏,因为我输了......
谢谢,迈克尔奥布莱恩

Hello all,

I just started doing heavy duty Access programming (not by choice) and I've run into a problem with the reports the company uses.

In one case some of the employees want to print only the comments(attached to a customer Number) that have a print flag checked. On the other hand they want to print all the comments attached to a customer. They have two sets of reports for doing this and I was wondering if it is possible to pass a criteria string that contains two...uhh...criterium(?).

This is how I have it set up now:

there are two buttons on the form one called cmdPrintCurrentComments and the other is cmdPrintComments


the first button that is meant to print all customer comments looks like this and works fine:
Private Sub cmdPrintComments_Click()
On Error GoTo Err_cmdPrintComments_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "CustomerReport"
   
    stLinkCriteria = "[Order Number] = '" & Me![Order Number] & "'"
    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Exit_cmdPrintComments_Click:
    Exit Sub

Err_cmdPrintComments_Click:
    MsgBox "Error occured in frmViewComments: cmdPrintComments_Click" & vbcrlf & "Error Description: " & Err.Description & vbcrlf & "Error Number: " & err.Number
    Resume Exit_cmdPrintComments_Click
End Sub


This is the second button and it doesn't work as its implemented here
Private Sub cmdPrintCurrentComments_Click()
On Error GoTo Err_cmdPrintCurrentComments_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "CustomerReport"
   
    stLinkCriteria = "[OrderNumber] = '" & Me![Order Number] & "' And (Comments.PrintFlag)=Yes"
    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Exit_cmdPrintCurrentComments_Click:
    Exit Sub

Err_cmdPrintCurrentComments_Click:
    MsgBox "Error occured in frmViewComments: cmdPrintCurrentComments_Click" & vbcrlf & "Error Description: " & Err.Description & vbcrlf & "Error Number: " & err.Number
    Resume Exit_cmdPrintCurrentComments_Click
End Sub


when I try to fire off the event it asks for Comments.PrintFlag like it should be a parameter and then if you put in yes it doesn't display any comments in the report.

any ideas would be much appreciated because I'm at a lose...
Thanks,

Michael O'Brien

推荐答案

Michael,

设置公共变量的值然后在查询中使用函数来获取值是一种经过验证的方法。
如果您需要帮助,请查看http://myaccessprogram.com/Tutorial.html,有一个免费的视频教程,名为
如何编写Visual Basic for Applications(VBA)功能。

Bob Heifler
MyAccessProgram.com

联系方式:
http://www.myaccessprogram.com/Contact.html

查找示例文件:
http:// www .myaccessprogram.com / Download.html

查找免费视频教程:
http://www.myaccessprogram.com/Tutorial.html
Michael,

Setting the value of a public variable then using a function in your query to get the value is a proven approach. 
If you need help with this check out http://myaccessprogram.com/Tutorial.html there is a free video tutorial called
How to write Visual Basic for Applications (VBA) functions.

Bob Heifler
MyAccessProgram.com

Contact information:
http://www.myaccessprogram.com/Contact.html

Find example files at:
http://www.myaccessprogram.com/Download.html

Find free video tutorials at:
http://www.myaccessprogram.com/Tutorial.html


这篇关于如何将多个变量发送到查询驱动的报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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