473,770 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Put Info from a data row to a listbox In VB6

12 New Member
Hi

I trying to get a single row of data onto a lisbox
Reason: It is a sales form i have created , what i would like to ultimately achieve is this, On the form there is a list box and dropdown combo and it is linked to data1, when the sales person clicks on the dropdown combo a list of items in the database appear via a dbgrid with that name: for example if he clicked on paint only the paint items would appear and the then from the dbgrid he selects the one withe correct description and it is added to the list box which would the form part of the reciept, then a button would be clicked to confirm the sale but i just cant seem to get the selected row in the dbgrid to be added to the listbox can this be done or am i going about it in completely the wrong way. Should I maybe use a multi line textbox ?

If so please tell i'm barking up the wrong tree and point direction to the right tree
I am using VB6 with access97

Many Thanks
Aug 27 '07 #1
2 1951
Sunray
12 New Member
Hi

I trying to get a single row of data onto a lisbox
Reason: It is a sales form i have created , what i would like to ultimately achieve is this, On the form there is a list box and dropdown combo and it is linked to data1, when the sales person clicks on the dropdown combo a list of items in the database appear via a dbgrid with that name: for example if he clicked on paint only the paint items would appear and the then from the dbgrid he selects the one withe correct description and it is added to the list box which would the form part of the reciept, then a button would be clicked to confirm the sale but i just cant seem to get the selected row in the dbgrid to be added to the listbox can this be done or am i going about it in completely the wrong way. Should I maybe use a multi line textbox ?

If so please tell i'm barking up the wrong tree and point direction to the right tree
I am using VB6 with access97

Many Thanks
Hey guys i got this thing to work for me
Here is the code

Private Sub Command1_Click( )
List1.Visible = True
Set db = DBEngine.Worksp aces(0).OpenDat abase("c:\Stock sdb1.mdb", False, False)
Set rs = db.OpenRecordse t("Select Distinct Surname from customers")
DoEvents
List1.Clear
rs.MoveFirst
While Not rs.EOF
List1.AddItem rs!Surname
rs.MoveNext
Wend
rs.Close
End Sub

Private Sub Command2_Click( )
List1.Visible = True
Set db = DBEngine.Worksp aces(0).OpenDat abase("c:\Stock sdb1.mdb", False, False)
Set rs = db.OpenRecordse t("Select Item from items")
DoEvents
List1.Clear
rs.MoveFirst
While Not rs.EOF
List1.AddItem rs!Item
rs.MoveNext
Wend
rs.Close
End Sub

This worked for hope some else out there can use it
Aug 30 '07 #2
VBPhilly
95 New Member
Hey guys i got this thing to work for me
Here is the code

Private Sub Command1_Click( )
List1.Visible = True
Set db = DBEngine.Worksp aces(0).OpenDat abase("c:\Stock sdb1.mdb", False, False)
Set rs = db.OpenRecordse t("Select Distinct Surname from customers")
DoEvents
List1.Clear
rs.MoveFirst
While Not rs.EOF
List1.AddItem rs!Surname
rs.MoveNext
Wend
rs.Close
End Sub

Private Sub Command2_Click( )
List1.Visible = True
Set db = DBEngine.Worksp aces(0).OpenDat abase("c:\Stock sdb1.mdb", False, False)
Set rs = db.OpenRecordse t("Select Item from items")
DoEvents
List1.Clear
rs.MoveFirst
While Not rs.EOF
List1.AddItem rs!Item
rs.MoveNext
Wend
rs.Close
End Sub

This worked for hope some else out there can use it
Thanks for replying when you found the solution
Aug 30 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1615
by: me | last post by:
I've included a picture below to show what I am trying to accomplish. It is best to copy/paste into notepad to get the spacing correct. I have a dataset that contains 3 tables. Two of the tables contain data and the third links them together. The dataset has a constraint setup as well. The first listbox and the first and last name text box are bound to the Person DataTable. As you select a name in the listbox, the textbox will be...
4
2769
by: Alienz | last post by:
I have a subform where I have a subform with 20 options to select from. When I set the multiselect property to simple and select multiple options, nothing is stored. I have another table with fieldID and fieldtype and I would like for evertime something is selected in the listbox for a new entry to be created with that fieldtype for the corresponding fieldID which is linked to the main form. Basically, how do I get info from the listbox...
3
2881
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
0
1538
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box that would Populate another Listbox/datagrid. Then it would cycle through the selections made in the populated listbox/datagrid and do some calculations. The calculations made would have to add the first two numbers in the populated...
0
1404
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box that would Populate another Listbox/datagrid. Then it would cycle through the selections made in the populated listbox/datagrid and do some calculations. The calculations made would have to add the first two numbers in the populated...
1
2780
by: A. Spiehler | last post by:
I'm trying to fill a listBox control with string members from an array of objects. I think using data binding is supposed to be the easiest way to do this. I've never used data binding before and am having trouble getting it to do anything. The relevant code is below, followed by a better explanation of what I'm trying to do. // pseudocode start public delegate string StepMethod();
2
1956
by: DartmanX | last post by:
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
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...
15
2372
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make things look better visually for that, I created a listbox under the text box. She enters the number in the text box, clicks another button I added and the number is stored in the list box. Then my plan was to grab all those numbers from the list box...
0
9595
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
9432
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
10232
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...
1
10008
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
9873
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
8891
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
6682
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
5313
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...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.