Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2007
    Posts
    30

    Unanswered: filling a combo box, method or data member not found

    I am trying to load a combo box in my vb app from a table held in sql, and no matter how i try, just cant seem to get this to work, can anyone tell me why?




    Private Sub Form_Load()

    Dim sql As String
    sql = "select * from T_country"

    Dim rsCountries As New ADODB.Recordset
    rsCountries.Open sql, cnn, adOpenStatic, adLockReadOnly


    With rsCountries
    .MoveFirst
    If Not .EOF Then
    Do Until .EOF
    CboCountries.AddItem rsCountries.Fields("Country")
    .MoveNext
    Loop
    End If
    End With

    Set CboCountries.DataSourceList = rsCountries


    rsCountries.Close
    Set rsCountries = Nothing



    End Sub

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Dim sql As String
    sql = "select country from T_country"
    Code:
    CboCountries.AddItem rsCountries.Fields("Country")
    '*--+ OR
    CboCountries.AddItem rsCountries.Fields(0)
    George
    Home | Blog

Posting Permissions

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