| re: Need to Pull Data from a ListBox to a Control
"DartmanX" <fergusonjason@gmail.com> wrote in
news:1147894685.907049.269620@j33g2000cwa.googlegr oups.com:
[color=blue]
> I have a form that does the following:
>
> - User inputs a serial number
> - VBA code does a lookup (SQL Query) and populates a listbox
> with results (4 columns in the Listbox)
> - Start Over (Listbox can contain up to 11 items)
>
> All that works perfectly.
>
> However, the next step is to read the data OUT of the listbox
> and into a report. However, I am unsure how to obtain all of
> the data from the listbox into some sort of array and populate
> the report.[/color]
[color=blue]
> I can leave the form open while the report is generated so
> that the listbox is accessible. However, I need help in what
> to do next.
>
> Any help is appreciated.
>
> Jason
>[/color]
Hopefully one of the 4 columns represents the primary key to the
table. Once you have your items selected into the listbox, you
need to walk the listbox and make a comma delimited list of
those primary key values. open the report, with a where clause
consisting of the primary key's field name IN (list)
mykeylist = "123,345,765,012" ' if numeric
mykeylist = """12A"",""33G"",""Z45""" ' if text.
(note the double doublequotes)
stWhere = "[myTableKeyField] IN (" & mykeylist & ")"
docmd.openreport"myReport,acpreview,,stWhere
--
Bob Quintal
PA is y I've altered my email address. |