473,406 Members | 2,220 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,406 software developers and data experts.

Put Info from a data row to a listbox In VB6

12
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 1935
Sunray
12
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.Workspaces(0).OpenDatabase("c:\Stocksdb1. mdb", False, False)
Set rs = db.OpenRecordset("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.Workspaces(0).OpenDatabase("c:\Stocksdb1. mdb", False, False)
Set rs = db.OpenRecordset("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
Hey guys i got this thing to work for me
Here is the code

Private Sub Command1_Click()
List1.Visible = True
Set db = DBEngine.Workspaces(0).OpenDatabase("c:\Stocksdb1. mdb", False, False)
Set rs = db.OpenRecordset("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.Workspaces(0).OpenDatabase("c:\Stocksdb1. mdb", False, False)
Set rs = db.OpenRecordset("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
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...
4
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...
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...
0
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...
0
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...
1
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...
2
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...
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...
15
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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...
0
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...
0
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...
0
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,...
0
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...

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.