多个组合框以及多个多选列表框报告 [英] Multiple Combo Boxes as well as multiple Multi select List Boxes toreport
问题描述
我如何根据从几个
组合框中选择的标准打印报告,以及多个多选列表框,即位于同一表格上的
?
我可以使用这个
我发现的
代码报告一个多列表框,只有不是几个 -
Private Sub cmdPreview_Click()
错误GoTo Err_Handler
Dim varItem As Variant''选定项目
Dim strWhere as String''字符串用作WhereCondition
Dim strDescrip As String''WhereCondition描述
Dim strDelim As String''此字段类型的分隔符。
Dim strDoc As String''报告的名称打开。
''strDelim ="""" ''分隔符适合现场类型。
见注释1.
strDoc ="产品分类
使用Me.lstCategory
每个varItem In .ItemsSelected
如果不是IsNull(varItem)那么
strWhere = strWhere& strDelim& .ItemData(varItem)&
strDelim& ","
''根据可见
列中的文字构建说明。请参阅注释2.
strDescrip = strDescrip& """" &安培; .Column(1,varItem)&
""","
结束如果
下一页
结束
lngLen = Len(strWhere) - 1
如果lngLen 0然后
strWhere =" [CategoryID] IN(& Left $(strWhere,lngLen)&")"
lngLen = Len(strDescrip) - 2
如果lngLen 0那么
strDescrip =" Categories:" &安培;左$(strDescrip,lngLen)
结束如果
结束如果
如果是CurrentProject。 AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport,strDoc
结束如果
DoCmd.OpenReport strDoc,acViewPreview,WhereCondition:= strWhere,
OpenArgs:= strDescrip
Exit_Handler:
退出Sub
Err_Handler:
如果Err.Number< 2501那么''忽略''报告已取消'"错误。
MsgBox"错误" &安培; Err.Number& " - &安培; Err.Description ,,
" cmdPreview_Click"
结束如果
恢复Exit_Handler
结束子
任何帮助都会得到极大的帮助!
非常感谢
Michael
How would i print a report based on criteria selected from several
Combo Boxes as well as multiple Multi Select List Boxes, that are
located on the same form?
I can get one Multi List Box, just not several, to report using this
code i found -
Private Sub cmdPreview_Click()
On Error GoTo Err_Handler
Dim varItem As Variant ''Selected items
Dim strWhere As String ''String to use as WhereCondition
Dim strDescrip As String ''Description of WhereCondition
Dim lngLen As Long ''Length of string
Dim strDelim As String ''Delimiter for this field type.
Dim strDoc As String ''Name of report to open.
''strDelim = """" ''Delimiter appropriate to field type.
See note 1.
strDoc = "Products by Category"
With Me.lstCategory
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
''Build up the description from the text in the visible
column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) &
""", "
End If
Next
End With
lngLen = Len(strWhere) - 1
If lngLen 0 Then
strWhere = "[CategoryID] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen 0 Then
strDescrip = "Categories: " & Left$(strDescrip, lngLen)
End If
End If
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc
End If
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
Exit_Handler:
Exit Sub
Err_Handler:
If Err.Number <2501 Then ''Ignore "Report cancelled" error.
MsgBox "Error " & Err.Number & " - " & Err.Description, ,
"cmdPreview_Click"
End If
Resume Exit_Handler
End Sub
Any help would be greatly apprciated!
Many thanks
Michael
推荐答案
(strWhere,lngLen)& ")"
lngLen = Len(strDescrip) - 2
如果lngLen 0那么
strDescrip =" Categories:" &安培;左
(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen 0 Then
strDescrip = "Categories: " & Left
(strDescrip,lngLen)
结束如果
结束如果
如果是CurrentProject.AllReports(strDoc).IsLoaded那么
DoCmd.Close acReport,strDoc
结束如果
DoCmd.OpenReport strDoc,acViewPreview,WhereCondition:= strWhere,
OpenArgs:= strDescrip
Exit_Handler:< br $>
退出Sub
Err_Handler:
如果Err.Number< 2501那么''忽略报告已取消错误。
MsgBox"错误" &安培; Err.Number& " - &安培; Err.Description ,,
" cmdPreview_Click"
结束如果
恢复Exit_Handler
结束子
任何帮助都会得到极大的帮助!
非常感谢
Michael
(strDescrip, lngLen)
End If
End If
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc
End If
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
Exit_Handler:
Exit Sub
Err_Handler:
If Err.Number <2501 Then ''Ignore "Report cancelled" error.
MsgBox "Error " & Err.Number & " - " & Err.Description, ,
"cmdPreview_Click"
End If
Resume Exit_Handler
End Sub
Any help would be greatly apprciated!
Many thanks
Michael
没有人可以帮助我吗?
No one can help me?
这篇关于多个组合框以及多个多选列表框报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!