|
-
Nov 13th, 2001, 01:21 AM
#1
Thread Starter
PowerPoster
Populating a Listbox with the Contents of a Field from a MDB
I need to populate a listbox with the contents of a field in a recordset of a MDB file. When the user clicks on one of the items in the list i need all the textboxes to be populated with thier fields in the same recordset.
Example: I have 15 textboxes, each one has the info of the 15 fileds in TblLetters. Field1 holds the names of the letters so it is named "Names". Well, i want to populate a listbox with all the "Names" and then when the user clicks on a Name the 15 textboxes are filled with thier coesponding Fields.
Any help is appreciated.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Nov 13th, 2001, 02:19 AM
#2
PowerPoster
Off the top of me head!
VB Code:
rs.movefirst
Do until rs.eof = true
list1.additem rs.fields("Names")
rs.movenext
Loop
-
Nov 13th, 2001, 02:35 AM
#3
Re: Populating a Listbox with the Contents of a Field from a MDB
Originally posted by Arc
I need to populate a listbox with the contents of a field in a recordset of a MDB file. When the user clicks on one of the items in the list i need all the textboxes to be populated with thier fields in the same recordset.
Example: I have 15 textboxes, each one has the info of the 15 fileds in TblLetters. Field1 holds the names of the letters so it is named "Names". Well, i want to populate a listbox with all the "Names" and then when the user clicks on a Name the 15 textboxes are filled with thier coesponding Fields.
Any help is appreciated.
Hello.....
Its so cool cool
Populate the list as in above reply
then
in List1_Click Event write this
if ur using ADO
Dim rsDisplayValues As New ADODB.Recordset ''For Displaying the values from table
rsDisplayValues.Open "Select * from <Tablenmae> " & _
"Where Name='" & list1.text & "' ", CnAccess, adOpenStatic, adLockOptimistic
Try and reply
Itty
-
Nov 13th, 2001, 02:45 AM
#4
Thread Starter
PowerPoster
Hi, thanks for the input.
One problem here. I'm using the Data object and here is my code.
Data1.Recordset.MoveFirst
Do Until Data1.Recordset.EOF = True
List1.AddItem Data1.Recordset.Fields("Names")
Data1.Recordset.MoveNext
Loop
With this code i get the error
"Object Variable or With Block Variable not set"
What the heck does that mean?
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Nov 13th, 2001, 02:49 AM
#5
Thread Starter
PowerPoster
NM i figured it out thanks. Now on to the next part =)
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Nov 13th, 2001, 04:27 AM
#6
Thread Starter
PowerPoster
OK, i thought i was clear sorry if i wasn't.
I am using the data control from VB. I think you know what i mean.
I am using an Access MDB Database. I am using the "Microsoft ADO ext. 2.5 for Dll and security" refrence to acces the database.
I am not sure what other info you need.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Nov 13th, 2001, 05:38 AM
#7
Can u pls send the sample code that u r working
It would a great help for me to continue
Itty
-
Nov 13th, 2001, 06:05 AM
#8
Thread Starter
PowerPoster
There is not any code to show you. I am using a data control it requires almost no code.
I simply link the data control to the Database MDB then i link the textboxes to the fields.. it's very simple.
I just need to know how to get the fields to display when i click on the names in a list box.
Example: I have a list populated with the Items in Field "names". There are 15 fields in this table. When i click on a name in the listbox i want the 15 textboxes to be populated with the items in that field. The textboxes are all conected to the Data1 object which is connected to the recordset/table Names.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Nov 14th, 2001, 08:32 PM
#9
PowerPoster
Using the datacontrol this worked for me!
VB Code:
Private Sub Command3_Click()
Data1.Recordset.MoveFirst
Do Until Data1.Recordset.EOF = True
List1.AddItem Data1.Recordset.Fields("Names")
Data1.Recordset.MoveNext
Loop
End Sub
Get rid of the ADO reference you dont need it!
But dont use datacontrols they really are bad mmmmmm kkkkkk
B
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|