473,840 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1958
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.R owSource), 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.goo glegroups.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,01 2" ' if numeric
mykeylist = """12A"",""33G" ",""Z45""" ' if text.
(note the double doublequotes)

stWhere = "[myTableKeyField] IN (" & mykeylist & ")"
docmd.openrepor t"myReport,acpr eview,,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
7883
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 allso subclassed the window and do see all kinds of WS_??? messages coming by. But now I'm stuck :-\ I've got *no* idea what to do next, and all my searching on the web leads me
19
4120
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 the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
1
2220
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 will respond to that. The problem is that with a listbox control (which is what it sounds like I need), I can't get the information to format at all. \t-Tabs skew the data unpredicatably - it leaves some words closer together on some lines than...
1
2039
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 property of the ListBox and populated it by DataBind method. But in such scenario ListBox's SelectedIndex property always returns -1 on postbacks. Could you please answer is it possible to know what item was selected by user in ListBox with view state...
3
2886
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 application or notepad where i want to paste it to be.How can i do it?If anyone knows source code or any website URL's please let me know. Umasakshi
1
1082
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 logic right or not. What I am trying to figure out is the process by which I pull the information. I'm trying to populate a list box with items where certain criteria are met.
4
2682
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 displayed in the Edit control.Exe have a Hunderds of items in the List controls,which display some text in edit control against an item selection. I want to read that data which is displayed in edit control against the selection of an item in list...
1
1884
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
1972
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 quiet and smiled. What is reflection!? I have been reading it up, and all I can work out is that it has something to do with Late Binding, and the use of GetType and Type.
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10657
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10299
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9436
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7836
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.