473,785 Members | 2,640 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 1956
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
7874
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
4109
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
2217
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
2037
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
2882
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
1079
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
2675
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
1881
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
1971
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
9645
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
9481
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,...
0
10336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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
8978
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...
0
6741
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();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.