|
-
Feb 15th, 2001, 02:07 PM
#1
Thread Starter
Junior Member
This is my first database project in VB. I have a couple of questions that I would like to ask. I guess I'll use access for the database. Would the person I give the program to have to have Access. Also if I have 20 lines of numbers in a list box, how do I save it to 20 columns?
And I would like to put it back in a list box later.
Thank you for your help
-
Feb 16th, 2001, 02:33 AM
#2
Well ...
You can use DAO to link to the Access Database from VB, and your client does not need to have Access installed on his machine.
As for your second question, the nature of the question is strange, as usually each item in the listbox is updated in one row of the table, and not one column. However if the number of columns in the table are exactly the same as the number of items in the list, it is possible:
Code:
Dim I As Integer
Dim rsTemp As RecordSet
'Code to populate the listbox, and open the recordset
rsTemp.AddNew
For I = 0 To List1.ListCount - 1 Step 1
rsTemp.Fields(I) = List1.List(I)
Next
rsTemp.Update
The above code will insert a new blank row into the recordset and update each value in the listbox into each column of the new row. However, the number of columns in the recordset must match the number of items in the listbox. Now for retrieving values from the table into the list, just the reverse of the above:
Code:
Dim I As Integer
Dim rsTemp As RecordSet
'Code to open the recordset
List1.Clear
rsTemp.MoveFirst
For I = 0 To rsTemp.Fields.Count - 1 Step 1
List1.AddItem rsTemp.Fields(I)
Next
.
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
|