This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C1EFA1.0A70EAF0
Content-Type: text/plain;
charset="iso-8859-1"
Thanks for the swift response.
I modified yours and did this:
Private Sub FillYourListBox()
Dim sql As String
Dim cls As clsDataSource
Set cls = New clsDataSource
sql = "SELECT UI_FNAME FROM USER_INFO"
With cls
.OpenRecordset sql
Do Until .rsRecSet.EOF
List1.AddItem .rsRecSet.Fields(0)
.rsRecSet.MoveNext
Loop
End With
End Sub
Private Sub Form_Load()
FillYourListBox
-----Original Message-----
From: Jack Dunstan [mailto:jdunstan7@h...]
Sent: Monday, April 29, 2002 10:56 AM
To: professional vb
Subject: [pro_vb] Re: populating listboxes
Hi,
there are many ways but here's one:
Private Sub FillYourListBox()
Dim rsYourRecordSet AS ADODB.Recordset ' or whatever type your going
to use
Set rsYourRecordSet = New ADODB.Recordset
'Open A Recordset Based On The Table
Dim sql As String
With rsYourRecordSet
If .State = adStateOpen Then
.Close
End If
.CursorLocation = adUseClient
sql = "SELECT [your fields] FROM [your table]"
' open the record set
.Open sql, YourConnection, adOpenForwardOnly, adLockReadOnly, adCmdText
' make sure there are records, if so populate the combo box
If .RecordCount > 0 Then
While Not .EOF
YourListBox .AddItem .Fields("FieldName").Value
.MoveNext
Wend
.Close
End If
End With
End Sub
hth
Jack
----- Original Message -----
From: "OB" <oby.atabansi@h...>
To: "professional vb" <pro_vb@p...>
Sent: Monday, April 29, 2002 3:19 PM
Subject: [pro_vb] populating listboxes
> I need a code snippet to populate a list box straight from a database
> table with user last name.
>
>
> Thanks,
>
> Oby.
>