Results 1 to 5 of 5

Thread: Delet a record when item is removed from a list view

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    Home
    Posts
    85

    Delet a record when item is removed from a list view

    Hi There, hope you can help!

    In my application I have a listbox listing select criteria with the following code -

    (VB Code -

    adoExpertise.Open "select * from tblExpertise INNER JOIN tblExpertiseRequirements ON tblExpertise.bytExpertiseCode = tblExpertiseRequirements.bytExpertiseCode where tblexpertiserequirements.lngVacancyID =" & FrmVacancy.txtFields(0).Text, db, adOpenStatic, adLockOptimistic
    List2.Clear

    Max = adosecondary.RecordCount
    adoExpertise.MoveFirst
    List2.Clear

    For i = 1 To Max
    List2.AddItem adosecondary!chrExpertise
    adoExpertise.MoveNext
    Next i

    end code)

    My problem is how to delete the selected item from the recordset when the item is removed from the list box by the user - Can anybody hep?


    Thanks in advance

    - PB

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    Home
    Posts
    85
    Whoops I made a mistake in the code as below

    For i = 1 To Max
    List2.AddItem adoExpertise!chrExpertise
    adoExpertise.MoveNext
    Next i

    The above code works to populate the listbox with the required items but i need help in deleting a selected item

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    Home
    Posts
    85

    Sorry just one more thing

    the table tblExpertiserequirements will contain the record that will require deleting
    - the tblExpertiserequirements table contains the following -
    lngVacancyID and bytExpertiseCode.

    So i am thinking we will have to open a recordset with the following sql statement =
    select * from tblexpertiserequirements inner join tblexpertise on tblexpertise.bytexpertisecode where where lngVacancyid = "& frmvacancy.txtfields(0).text and tblexpertise.chrExpertise = list2.selected

    .delete
    then delete the record

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    Home
    Posts
    85

    tried this and got syntax error!

    Hi There

    tried to use the sql statement below and got syntax error in where statement
    dim i as integer

    Set adoPrimaryRS = New Recordset
    adoPrimaryRS.Open "select * from tblExpertiseRequirements inner join tblExpertise on tblexpertise.bytexpertisecode where tblexpertise.chrexpertise =" & List2.Selected(i), db, adOpenStatic, adLockOptimistic

    if i dont use i as integer i get argument not optional error

  5. #5
    Lively Member
    Join Date
    Jun 2004
    Location
    Dubai, UAE
    Posts
    64
    Hi

    The ListBox values can be retrieved by

    List1.List(List1.ListIndex)

    Where List is a collection and the ListIndex is the Index of the selected item of the List. Use this with your SQL.


    Gs

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