Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

List boxes and ADOC Controls

Posted on 2003-02-21
3
Medium Priority
?
358 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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Screencast - Getting to Know the Pipeline

564 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