Hi,
I'll try to setup my question.
I have a form with a 2 listboxs(multiselect).
The first listbox I want to allow the user to select the report to run, 1 or up to 12 different reports.
The second list box I want to allow the user to select a office, 1 or up to 16.
The report source is a query, each report has a seperate query, due to different job title data.
Here my code so far:
=======================================================
Private Sub OK_Click()
On Error GoTo err_preview_report_click
Dim title, wclause, RO_name, ro
Dim frm As Form, ctl As Control
Dim varitm As Variant
Dim strlist As String
Dim strlsit2 As String
strlist = ""
Set frm = Forms![frm_srp_sal_ro]
Set ctl = frm![Ro_list]
For Each varitm In ctl.ItemsSelected
strlist = "" & ctl.ItemData(varitm) & ""
strlist2 = strlist2 & "" & ctl.ItemData(varitm) & "" & "or"
Next varitm
'For Each title In Me![report_list].ItemsSelected
' wclause = Me![report_list].ItemData(title)
'DoCmd.OpenReport reportname:=wclause, view:=acViewNormal, wherecondition:=rname
'DoCmd.OpenReport reportname:=wclause, view:=acViewNormal, wherecondition:="[Local_Dep] =" & Forms![frm_srp_sal_ro]![Ro_list]
'Next
'For Each title In Me![report_list].ItemsSelected
For Each ro In Me![Ro_list].ItemsSelected
Ro_list = Me![Ro_list].ItemData(ro)
' wclause = Me![report_list].ItemData(title)
'DoCmd.OpenReport reportname:=wclause, view:=acViewNormal, wherecondition:=rname
Next
' DoCmd.OpenReport reportname:=wclause, view:=acViewNormal, wherecondition:=rname
'Next
DoCmd.OpenReport reportname:="Account Clerk", view:=acViewNormal, wherecondition:=Ro_list
Me.report_list = ""
Me.[Ro_list] = ""
EXIT_OK_CLICK:
Exit Sub
======================================
As you can tell I'm still trying to work out how to cycle through the selections and then how to process them.
Thanks to all that reply,
TC
err_preview_report_click:
MsgBox "Select a report!"
Resume EXIT_OK_CLICK
End Sub
I'll try to setup my question.
I have a form with a 2 listboxs(multiselect).
The first listbox I want to allow the user to select the report to run, 1 or up to 12 different reports.
The second list box I want to allow the user to select a office, 1 or up to 16.
The report source is a query, each report has a seperate query, due to different job title data.
Here my code so far:
=======================================================
Private Sub OK_Click()
On Error GoTo err_preview_report_click
Dim title, wclause, RO_name, ro
Dim frm As Form, ctl As Control
Dim varitm As Variant
Dim strlist As String
Dim strlsit2 As String
strlist = ""
Set frm = Forms![frm_srp_sal_ro]
Set ctl = frm![Ro_list]
For Each varitm In ctl.ItemsSelected
strlist = "" & ctl.ItemData(varitm) & ""
strlist2 = strlist2 & "" & ctl.ItemData(varitm) & "" & "or"
Next varitm
'For Each title In Me![report_list].ItemsSelected
' wclause = Me![report_list].ItemData(title)
'DoCmd.OpenReport reportname:=wclause, view:=acViewNormal, wherecondition:=rname
'DoCmd.OpenReport reportname:=wclause, view:=acViewNormal, wherecondition:="[Local_Dep] =" & Forms![frm_srp_sal_ro]![Ro_list]
'Next
'For Each title In Me![report_list].ItemsSelected
For Each ro In Me![Ro_list].ItemsSelected
Ro_list = Me![Ro_list].ItemData(ro)
' wclause = Me![report_list].ItemData(title)
'DoCmd.OpenReport reportname:=wclause, view:=acViewNormal, wherecondition:=rname
Next
' DoCmd.OpenReport reportname:=wclause, view:=acViewNormal, wherecondition:=rname
'Next
DoCmd.OpenReport reportname:="Account Clerk", view:=acViewNormal, wherecondition:=Ro_list
Me.report_list = ""
Me.[Ro_list] = ""
EXIT_OK_CLICK:
Exit Sub
======================================
As you can tell I'm still trying to work out how to cycle through the selections and then how to process them.
Thanks to all that reply,
TC
err_preview_report_click:
MsgBox "Select a report!"
Resume EXIT_OK_CLICK
End Sub