S
Steve Taber
I have the below code to select a report from a list box and then open the
specific report. In it's current status it just prints the report, and I want
to have it open as a preview. I have tried to insert the acView Preview
command, but I can't get it to work. Any ideas?
Private Sub Command5_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!List21.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!List21.ItemsSelected
' Grab the CompanyID column for each selected item
strWhere = strWhere & Me!List21.Column(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the companies form filtered on the selected companies
strWhere = "[Number] IN (" & strWhere & ")"
Debug.Print strWhere
DoCmd.OpenReport ReportName:="rptIncidentReport", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub
specific report. In it's current status it just prints the report, and I want
to have it open as a preview. I have tried to insert the acView Preview
command, but I can't get it to work. Any ideas?
Private Sub Command5_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!List21.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!List21.ItemsSelected
' Grab the CompanyID column for each selected item
strWhere = strWhere & Me!List21.Column(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the companies form filtered on the selected companies
strWhere = "[Number] IN (" & strWhere & ")"
Debug.Print strWhere
DoCmd.OpenReport ReportName:="rptIncidentReport", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub