Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send list box multiple selection to a report

Status
Not open for further replies.

smc

Technical User
Mar 13, 2000
3
US
Access Guru's...<br>Please tell me how to LinkCriteria from a multiple selection in a List box to a report.&nbsp;&nbsp;I am playing around with the following code but somethings missing.<br>Thanks for any assistance.<br>SMC<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim stDocName As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim stLinkCriteria As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim frm As Form, ctl As Control<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim varItm As Variant<br>&nbsp;&nbsp;&nbsp;&nbsp;Set frm = Forms!frmFPSearch<br>&nbsp;&nbsp;&nbsp;&nbsp;Set ctl = frm!List0<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;stDocName = &quot;FpSupplierProductList&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;For Each varItm In ctl.ItemsSelected<br>&nbsp;&nbsp;&nbsp;&nbsp;stLinkCriteria = &quot;[ID]=&quot; & ctl.ItemData(varItm)<br>&nbsp;&nbsp;&nbsp;&nbsp;Next varItm<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenReport stDocName, acPreview, stLinkCriteria<br>&nbsp;&nbsp;&nbsp;&nbsp;
 
Well in short you have to get the recordsource of the list box in a recordset somehow and pass it to the report.<br>There may be a post a way's back on that.
 
You might want to try...<br><FONT FACE=monospace><br>stLinkCriteria = &quot;[ID] IN (&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>For Each varItm In ctl.ItemsSelected<br>&nbsp;&nbsp;&nbsp;&nbsp;stLinkCriteria = stLinkCriteria & &quot;<font color=red><b>'</b></font>&quot; & ctl.ItemData(varItm) & &quot;<font color=red><b>', </b></font>&quot;<br>Next varItm<br><br>stLinkCriteria = Left(stLinkCriteria,Len(stLinkCriteria) - 2) & &quot;)&quot;<br><br>DoCmd.OpenReport stDocName, acPreview, stLinkCriteria<br></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br> <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
 
Jim,<br>Thanks for the effort, but, report prints &quot;all&quot; records - not ItemsSelected.&nbsp;&nbsp;Please .... try again!<br><br>Thanks,<br>SMC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top