Results 1 to 5 of 5

Thread: DBlist Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Edgerton, WI
    Posts
    381
    I have a DBList control 9dbListType)on one of my forms that displays to contents of a field in my database. The DBlist control is connected to a data control (datType). The capyion of the Data Control displays the current record.

    As I step through the list using the data control everything works fine. However, if I click on an item in the list I would like the data control to move to that record. For instance, if the data control is currently at record 10 of 100, the 10th record is hilighted in the list control. However, if I now click on record 15 in the list control, although it now becomes hilighted, the data control remains at record 10. How can I get the record to reflect whatever record I click on in the DBList as well?

    The problem is if I cycle through the list with the data control and delete a record it will delete the current record. However, it I move to record 15 in the DBList and the data control is still on record 10, then record 10 will be deleted, instead of the desired record 15 as hilighted in the dblist.

    Sometimes it's easier to scroll through the list and select the record than it is to cycle through them with the data control.

    Any help here would be most appreciated.

    Rev. Michael L. Burns

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Location
    Holden Beach NC
    Posts
    85
    Originally posted by Rev. Michael L. Burns
    I have a DBList control 9dbListType)on one of my forms that displays to contents of a field in my database. The DBlist control is connected to a data control (datType). The capyion of the Data Control displays the current record.

    As I step through the list using the data control everything works fine. However, if I click on an item in the list I would like the data control to move to that record. For instance, if the data control is currently at record 10 of 100, the 10th record is hilighted in the list control. However, if I now click on record 15 in the list control, although it now becomes hilighted, the data control remains at record 10. How can I get the record to reflect whatever record I click on in the DBList as well?

    The problem is if I cycle through the list with the data control and delete a record it will delete the current record. However, it I move to record 15 in the DBList and the data control is still on record 10, then record 10 will be deleted, instead of the desired record 15 as hilighted in the dblist.

    Sometimes it's easier to scroll through the list and select the record than it is to cycle through them with the data control.

    Any help here would be most appreciated.

    Rev. Michael L. Burns
    The easiest thing to do to ensure that your data bound list and your data control are in-sync is to use the data item's key in the .ItemData property of the list control. When you want to delete the record use an SQL statement to do the delete and then refresh your data control....

    txtSQL = "DELETE........WHERE TableName.KeyField = dbList1.ItemData(dbList1.ListIndex)"

    db.execute Sql

    (Assumes that you have opened a data base connection called db)

    The other way of handling this would be to attatch code to the click event of the List so that the data control was forced to move to the record that you clicked on.

    Hope that this helps

    Hunter

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Edgerton, WI
    Posts
    381
    Thanks HunterMcCray.

    I was thinking about the click event in the dblist but am confused how this could be done. Can you provide an example to work from?

    Thanks,
    Rev. Michael L. Burns

  4. #4
    Lively Member
    Join Date
    Aug 2000
    Location
    Holden Beach NC
    Posts
    85
    Dear Rev Burns,

    I do not use the dbList control. I use an unbound List control and I populate it from code. I think that you might be better off using the dbGrid control if you want to use bound controls. I know that it stays in-sync with the data control. Ie if you move to the next record in the recordset the dbgrid control responds and vice-versa.

    Hope this helps,

    Hunter

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Edgerton, WI
    Posts
    381
    Thanks Hunter for the input. Have a nice day.

    Rev. Michael L. Burns

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