473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need to Pull Data from a ListBox to a Control

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.

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

May 17 '06 #1
2 1938
Why don't you use the SQL query to directly populate the listbox
(choose SQL query as rowsource). Then you can read out the rowsource
(Me.MyListBox.RowSource), being a valid SQL statement, and use that as
basis for your Report.

May 17 '06 #2
"DartmanX" <fe***********@gmail.com> wrote in
news:11**********************@j33g2000cwa.googlegr oups.com:
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. 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

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.
May 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
1
by: ericm1155 | last post by:
I am trying to display some information from a database in a form that displays one record per line. When the user clicks anywhere on a line, that record is highlighted and selected, and my program...
1
by: Sergey Krutous | last post by:
Hi. I am developing composite web control which contains a ListBox. I'd like to minimize the amount of data transfered in view state to the client and back, so I set to false EnableViewState...
3
by: Uma sakshi | last post by:
Hi I have one VB.NET application,in that application i have one datagrid control.The datagrid control contains somedata.I want to copy the data in a particular cell and paste it into my C#.NET...
1
by: Ddraig | last post by:
Howdy, I've got a little project going and I am trying to figure out a good way to do this. But since I'm still learning I'm probably missing a few obvious steps. Also not sure if I have my...
4
by: CrimeMaster | last post by:
HI I have an Exe file when it runs ,there are just two controls on the window.One is a ListBox and another is a Multi line Rich Edit control.When i click on an item in the list some text is...
1
by: pooja | last post by:
i need to implement drag and drop in treeview in VB. Kindly help. My treeview contains activities maintained using XML Files. Hopefully, Thanks.
6
by: Cralis | last post by:
Hi guys, Someone once said, 'You can do that with reflection'. I can't recall what it was I was trying to do at the time, but then he said, 'Any developer knows what reflection is...'. I kept...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.