John W. Vinson[MVP]
Thank You very much for your help....
You are right Your Suggestion is True..
-------------------------------------------
It seems that you want to search the field
GroupNumber for the numeric values in the listbox named Listselect on
the form named frmreport, and then (I presume) launch a Report based
on those values... right?
I'd suggest then using VBA code to launch the report from a command
button on the form. Let's say you have a command button cmdReport on
frmreport. Its click event could be something like:
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click
Dim DocName As String
Dim strSQL As String
Dim varItem As Variant
' See if the user selected anything at all
If Me!Listselect.ItemsSelected.Count = 0 Then
MsgBox "Please select which items you want to print"
GoTo Exit_CmdReport_Click
End If
' Specify which report you want to open
DocName = "YourReportNameHere"
' Loop through the selected items in the Listbox,
' building up a legal SQL WHERE clause
strSQL = "[GroupNumber] IN ("
' The ItemsSelected property of the listbox is a collection of
' all the items the user has selected. Loop through all of them...
For Each varItem In Me!Listselect.ItemsSelected
' If the user selects rows with values 3, 65, 92 this will build a
' text string like
' "[GroupNumber] IN (3, 65, 92, "
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem
' Now trim off the closing comma and blank and put on a closing
' parenthesis
strSQL = Left(strSQL, Len(strSQL) - 2) & ")"
' Open the Report using strSQL as the WhereCondition
' use acViewNormal instead of acViewPreview to print the report
' immediately
DoCmd.OpenReport DocName, acViewPreview, , strSQL
Exit_cmdReport_Click:
Exit Sub
Err_cmdReport_Click
:
MsgBox Err.Description
Resume Exit_cmdReport_Click
End Sub