|
-
Jun 30th, 2004, 01:41 AM
#1
Thread Starter
Lively Member
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
-
Jun 30th, 2004, 01:45 AM
#2
Thread Starter
Lively Member
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
-
Jun 30th, 2004, 01:58 AM
#3
Thread Starter
Lively Member
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
-
Jun 30th, 2004, 03:39 AM
#4
Thread Starter
Lively Member
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
-
Jun 30th, 2004, 03:58 AM
#5
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|