MultiSelect List Box to Query Help Needed Please

T

TJ

I have a form named Raybestos ProductLine Update called first as part of a
macro. The form now has a Multi Select List Box named ProductLine that has
a Table/Query Row Source of Select [ProductLine].[Category],
[ProductLine].[Number] From [ProductLine]. The Bound column is #2 the
[ProductLine].[Number] column. When the multiple Product Categories are
selected, I need to pass the associated Number(s) to the query as parameter
[Forms]![Raybestos ProductLine Update]![ProductLine].

An example of the Table ProductLine is:
Category: Master Cylinder Number: 101
The column properties are: Category = Text and Number = Number.
There are 47 possible categories and associated numbers.

Researching a suggestion from Gary Miller to use a Multi Select List Box, I
found some code from Dev Ashish listed below. I think I am close but it
still does not work. I think I want to use the After Update element
because the initial Macro calls two queries back to back once the OK Button
is clicked that needs the Multi selected Numbers put into the queries. The
queries work great with a single selection Drop Down Box passed as
[Forms]![Raybestos ProductLine Update]![ProductLine]. I need to pass the
multi select numbers to the query now.

Thanks for your help!!



Private Sub ProductLine_AfterUpdate()
Dim strVal As String, varItm As Variant
strVal = ""
For Each varItm In Forms![Raybestos ProductLine
Update]!ProductLine.ItemsSelected
strVal = strVal & Forms![Raybestos ProductLine
Update]!ProductLine.ItemData(varItm) & ", "
Next varItm
'Trim the last , and space
strVal = Left$(strVal, Len(strVal) - 2)

Forms![Raybestos ProductLine Update]![ProductLine] = strVal

End Sub
 
P

PC Datasheet

Email me if you would like my help.

Steve
PC Datasheet
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top