Results 1 to 2 of 2

Thread: List1.Additem

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    Eastern Kentucky
    Posts
    14

    Question

    could someone teach me how to load a list box with a Sql Statement. thanks

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    82
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width