473,382 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problems with deleteing from a list box.

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
Jul 17 '05 #1
1 1889
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" <kt*******@getnet.net> wrote in message
news:fn*************@dhcpdns2.ddsoho.com...
: 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

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Jim Hubbard | last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework? Not if you are unaware of the 1,596 issues listed at KBAlertz (http://www.kbalertz.com/technology_3.aspx). If you are...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
6
by: Smokey Grindle | last post by:
I need to ensure that there are NO files in the target folder of a setup project, I want to delete anything in the folder first before the install takes place (all from inside the installer program...
3
by: timmy | last post by:
i make a copy of a list, and delete an item from it and it deletes it from the orginal as well, what the hell is going on?!?!?! #create the staff copy of the roster Roster2 = for ShiftLine in...
2
by: mankolele | last post by:
Hi all I am stuck in a situation where I have products in a table where they are all listed as available and there is a form to where they are given to people.What I want to happen is when an item is...
6
by: Nick Keighley | last post by:
Hi, Is this code fundamentally broken? class B { } class D: public B {
5
twillie
by: twillie | last post by:
Hello, I have a linked list in C++ and I am trying to remove all duplicate nodes from the list. The code below is what our prof. wrote on the board in pusdo code in class, yet it doesn't seem to...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
1
by: tytyguy | last post by:
Ok so I have an xml file that list image urls like this.... <imageurl>http://www.tirerack.com/images/tires/kumho/ku_victoracer_s.jpg</imageurl> I would like to be able to use xslt to transform...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.