Results 1 to 6 of 6

Thread: DataList Control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Post

    I am using VB6.

    I have bound my DataList1 to the Adodc1 data control.

    Is it possible to add data from DataList1 to DataList2 ?

    If so what code would I use ?


  2. #2
    Junior Member
    Join Date
    Nov 1999
    Posts
    16

    Post

    What is the RowSource for DataList2 (another ADO data control, based on some table)? Do you want to update this table?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Post

    Yes, DataList 2 is bound to another Data Control which is linked to a different table. I want to update this table.

    What are the possibilities ?

  4. #4
    Junior Member
    Join Date
    Nov 1999
    Posts
    16

    Post

    Assuming (for simlicity) both tables have only one field ("fld") which is a ListField for both DataList controls, you can try this:

    If Not IsNull(DataList1.SelectedItem) Then
    Adodc1.Recordset.Bookmark = DataList1.SelectedItem
    Adodc2.Recordset.AddNew
    Adodc2.Recordset!fld = Adodc1.Recordset!fld
    Adodc2.Recordset.Update
    Else
    MsgBox "Please, select an item.", vbExclamation
    End If

    This is an idea, you can customize it for your needs.

    Hope that helps. Best regards, Vlad

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Post

    Thank you vlad, that was excellent.Can you help me further please ?

    I have 10 names in DataList1 and I want to move 5 into DataList2 Before I update the Table linked to DataList2. How can I achieve this transfer from one DataList Box to another.



  6. #6
    Junior Member
    Join Date
    Nov 1999
    Posts
    16

    Post

    You can use batch updates, if they are supported by your database provider.

    Try the following:

    1. Set LockType property for Adodc2 to adLockBatchOptimistic.
    2. Remove Adodc2.Recordset.Update from the click event for the button you use to transfer items from one list for another.
    3. Add another button for updating Table2, put Adodc2.Recordset.UpdateBatch for the click event for this button.

    You can use Adodc2.Recordset.CancelBatch to cancel updates.

    Another option could be using standard list box controls instead of DataList. In this case you can fill the first list programmatically, and then, when the user transfers some items to the second list, programmatically add them to the second table.

    Vlad

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