|
-
Dec 14th, 2001, 10:05 AM
#1
Thread Starter
Hyperactive Member
Populating a ListBox
I need a function which retrieves all the datas of a specific
field and add it to the listbox.?
This code below returns only the last data of the field :
Private Sub Cmd_onClick()
lstname.AddItem GetProdList()
End Sub
Public Function GetProdList() As Variant
Dim list As Variant
Set rsp = New ADODB.Recordset
rsp.Open "select * from product", cn, adOpenDynamic, adLockOptimistic
Do While Not rsp.EOF
list = rsp(0)
GetProdList = list
rsp.MoveNext
Loop
End Function
How do I proceed?
Note: I need to compulsorily use a function to do this.
-
Dec 14th, 2001, 10:10 AM
#2
Try something like
VB Code:
Private Sub cmdAddDates_Click()
Set rsp = New ADODB.Recordset
rsp.Open "SELECT datefield FROM product", cn, adOpenDynamic, adLockOptimistic
Do While Not rsp.EOF
List1.Additem rsp(0)
rsp.MoveNext
Loop
End Sub
-
Dec 14th, 2001, 10:16 AM
#3
Thread Starter
Hyperactive Member
But I need to have it in a function and call it recursively.
-
Dec 14th, 2001, 10:19 AM
#4
-
Dec 14th, 2001, 10:19 AM
#5
Frenzied Member
You mean something like this?
VB Code:
Private Sub PopulateListBox (lst as ListBox)
Set rsp = New ADODB.Recordset
rsp.Open "SELECT datefield FROM product", cn, adOpenDynamic, adLockOptimistic
Do While Not rsp.EOF
lst.Additem rsp("FieldName")
rsp.MoveNext
Loop
End Sub
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
|