?
Solved

List boxes and ADOC Controls

Posted on 2003-02-21
3
Medium Priority
?
346 Views
Last Modified: 2010-04-17
What is the code to for a list box, that when an item is selected it will display the apporiate information that coincides with that item.  There is a database connected to the form using an ADOC control.  For example lets say there is a list box that contains the names of people and when one of the names is selected in the list another form will open to display that person's infomation.
0
Comment
Question by:bikerChic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
JoaTex earned 150 total points
ID: 7996744
Hi There

Let's see if it's this that you Want

Suposing that the 3 First Fields on your data base are:
Client, Name, Adress

Create a listBox that lists:
Client
Name
Adress

This listIndex should be the same as your FieldsIndex database.

Now you must index the record to those fields EX:
Data1.recordset.absolute position=10

now on your sub List1Click()you must have:
Text1.Clear
Text1.text = list1.list(list1.listindex)

When you select name on listbox Text1 wil be the name of your database.

hope this suites you
Sorry about my english.
Jo
0
 

Author Comment

by:bikerChic
ID: 7997120
Thanks I will try it I am not fimilar with ADOC I only know DAO.
0
 
LVL 3

Expert Comment

by:abbasi1
ID: 7998193
if u want to get info from any table through listbox
just suppose u have only two fields in ur table place two text boxes and a command button and a datalistbox
it normaly not appears on the tool box u have to add it from components by right clicking the
 toolbox/components/microsoft DataListContols(OLEDB)6.0
place it on the pro ject and copy this code in code window



' the code starts here

Option Explicit
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset

Private Sub Command1_Click()
Dim a As String
a = "select * from pw1 where u_name='" & DataList1.Text & "'"           ' run  this query just suppose ur table name is pw1
Set rs = db.Execute(a)

MsgBox rs(0)
 Text1.Text = rs(0)
Text2.Text = rs(1)
End Sub

Private Sub Form_Load()
Set db = New ADODB.Connection
Set rs = New ADODB.Recordset

db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\hello\pw.mdb"   and ur database path is like that
     '     ^                    '     ^          
     '     |                    '     |
     'and ur database type'          'there u have to
' write down the path of ur data base'                                        

End Sub
'the code ends here

from
Abbasi
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question