PDA

Click to See Complete Forum and Search --> : List1.Additem


dbowling
Nov 3rd, 2000, 08:16 PM
could someone teach me how to load a list box with a Sql Statement. thanks

AdrianH
Nov 3rd, 2000, 11:13 PM
Hi
Assuming you wish to use a standard list box, not a DBList box control. See below.

Dim rcsBookDefine as recordset
Dim SQLStatement as string

lstFaultType.clear
SQLStatement = "Select * from [Fault Codes] order by [Fault Code Number]"
Set rcsBookDefine = MainDB.OpenRecordset(SQLStatement)
With rcsBookDefine
If .RecordCount > 0 Then
.MoveLast: .MoveFirst
Do While Not .EOF
lstFaultType.AddItem ![Fault Code Description]
.MoveNext
Loop
End If
.Close
End With

Hope this is of assistance.