Wait are you running a Macro or the code I gave you... I'm a little confused. As for how...
You have a little Form that opens prior to the Report, you make your selections from whatever controls you have on the Form and click the Preview Button OR you can just send them out to a file. Either way it makes it easier to say, I want to see all or one because it becomes a selection on the Form. Make sense?
I am running this:
Sub mcrSelectedExport(ctrl As Control)
Dim varItem As Variant
Dim m_agenda_id_list As String
Dim strSQL As String
Dim rs As DAO.Recordset
' loop through list box and build value list
For Each varItem In ctrl.ItemsSelected
m_agenda_id_list = m_agenda_id_list & "," & ctrl.ItemData(varItem)
Next varItem
' remove leading comma
m_agenda_id_list = Mid(m_agenda_id_list, 2)
' build SQL statement restricted to selected items
' by means of an IN operation in the WHERE clause
strSQL = "SELECT m_agenda_id " & _
"FROM m_agenda " & _
"WHERE m_agenda_id IN(" & m_agenda_id_list & ") " & _
"ORDER BY m_agenda_kod"
Set rs = CurrentDb.OpenRecordset(strSQL)
With rs
Do Until .EOF
DoCmd.OpenReport "rpt_MAIN_REPORT", _
acViewPreview, _
WhereCondition:="M_AGENDA_ID = " & !M_AGENDA_ID, _
WindowMode:=acHidden
DoCmd.OutputTo acOutputReport, _
"rpt_MAIN_REPORT", _
acFormatPDF, _
"C:\Users\martin.janota\Desktop\test formularu\Master\webtest\Master\ " & !M_AGENDA_KOD & ".pdf"
DoCmd.Close acReport, "rpt_MAIN_REPORT", acSaveNo
.MoveNext
Loop
.Close
End With
End Sub
I created form lst_m_agenda, where have list box with multiple selection property named mcrSelectedExport Me.lst_m_agenda. Then i have button there. I set up on click event mcrSelectedExport Me.lst_m_agenda.
And i got message: "MS Access cannot find the object mcrSelectedExport Me."
Btw i cannot see mcrSelectedExport when i am trying to run code right from VB.
:banghead: