Results 1 to 5 of 5

Thread: selecting Data in combobox

  1. #1

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

    Angry

    What is wrong with this statement?
    using vb6 with sp4. Trying to populated text boxes with data from ado database. Vb6 crashes when this sub is run

    Private Sub ItemSelected()
    sSql = "Select * From Customertable Where Name = '" _
    & DBCombo1.Text & "'"
    Set Data1.Recordset = Data1.Database.OpenRecordset(sSql)
    End Sub

    I can add a msgbox to this sub and it will not crash but it will add 2 copies of whatever is selected and clear remaining items in combobox?


    thanks

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    i am very bad with data control
    why dont you use pure ado instead of the ado control?
    its much easier and better


  3. #3

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

    Talking

    I really want to learn to do this and I cannot quit because this is fastest way I have found to search this database which is about 2000 records long. So if someone could respond with an answer of teach me a better way to search this customer list.
    Again thanks

  4. #4
    Guest
    Hi, firstly let me tell u this is not the complete solution. The purpose of this is to try and give an idea. Firstly, i think u ought to use...
    ---combo1.list(combo1.listindex)--- to get the selected item.

    Secondly, take pains in debugging the Sql statement before u run it.

    Thirdly, before u populate the combo box make sure u delete the previous contents in it. May be that is the reason u are getting them twice.

    Fourthly, i think a general feeling among the programmer community is not to use data controls as they dont give u as much control over the data as the code does.

    Hope this would give u some idea and help u in deciding for urself. Feel free to mail to gantibabu@yahoo.com.

    All the best...vijay

  5. #5
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196
    Have you tried placing a Doevents before the end sub


    e.g.



    your code...

    doevents

    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
  •  



Click Here to Expand Forum to Full Width