Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
Problems with deleteing from a list box.
Old
  (#1)
Rev. Karl E. Taylor
Guest
 
Posts: n/a
Default Problems with deleteing from a list box. - 06-04-2007, 09:49 AM

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
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Problems with deleteing from a list box.
Old
  (#2)
Randy Birch
Guest
 
Posts: n/a
Default Re: Problems with deleteing from a list box. - 06-04-2007, 09:49 AM

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

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top