NewIndex is only valid when the item has been added. The index of the item
you want to delete is the selected item index, aka list1.listindex.
--
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"Rev. Karl E. Taylor" <EMAIL REMOVED> wrote in message
news:fne902-EMAIL REMOVED...
: Okay, what am I doing wrong here?
:
__________________________________________________ ___________________________
: From oprecs.bas module:
:
: Public tapeRec As New HB_Recordset
: Public Const ttape As String =
: "mDeAA1oO0q6q_okrD83qusByEmg97TD1Ug7wRFKOW=Zry Xa"
: tapeRec.OpenTable "H:\HB_projects\pdaemi_win\ddph_tbltapes.pdb", ttape
:
: From Form1_load():
:
: 'Populate tape List
:
: If Not tapeRec.EOF Then
: tapeRec.MoveFirst
: End If
: While Not tapeRec.EOF
:
: lsttapes.AddItem tapeRec!tape
: lsttapes.ItemData(lsttapes.NewIndex) = tapeRec!UniqueId
: lsttapes.Text = tapeRec!tape
: tapeRec.MoveNext
:
: Wend
:
: From lsttapes_Click()
:
: Private Sub lsttapes_Click()
: Dim tapeRec As New HB_Recordset
: 'ttape = "mDeAA1oO0q6q_okrD83qusByEmg97TD1Ug7wRFKOW=Zry Xa"
: tapeRec.OpenTable "H:\HB_projects\pdaemi_win\ddph_tbltapes.pdb", ttape
:
: While Not tapeRec.EOF
: If tapeRec!tape = lsttapes.Text Then
:
: txttape.Text = tapeRec!tape
: txtAmt.Text = tapeRec!amount
: txtFreq.Text = tapeRec!Frequency
: txtUID.Text = tapeRec!UniqueId
:
: End If
: tapeRec.MoveNext
: Wend
: tapeRec.Close
:
: End Sub
:
: From tapeDel_Click()
:
: Private Sub tapeDel_Click()
: Dim tapeRec As New HB_Recordset
:
: 'Dim loc As Integer
: 'ttape = "mDeAA1oO0q6q_okrD83qusByEmg97TD1Ug7wRFKOW=Zry Xa"
: tapeRec.OpenTable "H:\HB_projects\pdaemi_win\ddph_tbltapes.pdb", ttape
:
: tapeRec.LookupUniqueID (lsttapes.NewIndex)
: tapeRec.Delete hbRecordRemove
:
: ' While Not tapeRec.EOF
: ' tapeRec.Delete hbRecordRemove
: ' tapeRec.MoveNext
: ' Wend
:
: txttape.Text = " "
: txtAmt.Text = " "
: txtFreq.Text = " "
: lsttapes.RemoveItem (lsttapes.NewIndex)
:
:
:
:
: 'tapeRec.Close
:
: End Sub
:
:
__________________________________________________ ________________________________
: For some odd reason, and I'm unsure as to why, when I go to delete a
: recored, it either deletes the last in the list, or gives me all kinds
: of errors.
:
: --
:
: Karl E. Taylor