Results 1 to 2 of 2

Thread: DataList jumps to next in list

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    4

    DataList jumps to next in list

    I have solved my previous problem but face a new one now. Perhaps someone can help.

    I have a MS SQL 2000 database. I use two tables from that database. Two different ADOdc's connect to a table. One table contains information about companies and the other contains contactpersons from those companies.

    In my form I have a DataCombo with following properties:

    BoundColumn = Companyname
    DataField = Companyname
    Datasource = Contactpersons
    ListField = Companyname
    RowSource = Companies

    Also in my form is a DataList and properties are:

    BoundColumn = Companyname
    DataField = NameOfContact
    Datasource = Contactpersons
    ListField = NameOfContacts
    RowSource = (is empty)


    A third ADOdc called Name, is used to store the rows that are the same in both tables, resulting in a list of contactpersons for a specific company.

    Code in the form is:

    VB Code:
    1. Option Explicit
    2.  
    3. Private DeleteContact As String
    4.  
    5. Private Sub DataCombo1_change()
    6. Dim query As String
    7.    
    8.     gstrContact = DataCombo1.Text
    9.    
    10.     query = "SELECT * FROM Contactpersons WHERE CompanyName = '" & gstrContact & "' ORDER BY Name"
    11.    
    12.     Name.RecordSource = query
    13.     Name.Refresh
    14.     Set DataList1.RowSource = Name
    15.     DataList1.Refresh
    16.  
    17. End Sub
    18.  
    19. Private Sub Form_Load()
    20.  
    21. ContactPersons.Recordset.AddNew
    22.    
    23.     DataCombo1.Text = ""
    24.  
    25. End Sub


    Now what is the problem?

    When the form opens, I can go to DataCombo1 and select a company. When a company is chosen, all the contacts of that company are visible in DataList1.

    I then select a name by clicking it.

    And then the problem comes.

    When I push a button that I have on my form, the NEXT name in my DataList1 gets selected. Why, I don't know. It's like a lostfocus was written somewhere to jump to the next one in the list. I cannot seem to find the solution.

    I wanted to delete the selected person, but because the next one in the list gets selected when I push the delete button, the wrong person gets deleted.

    Good thing I made a backup of my database before trying this.

    Anyone who can help?

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: DataList jumps to next in list

    Quote Originally Posted by pthomass
    When I push a button that I have on my form, the NEXT name in my DataList1 gets selected.
    Would you post the code for tat button?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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