Results 1 to 8 of 8

Thread: [RESOLVED] deleting problem ... error 3021

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    287

    Resolved [RESOLVED] deleting problem ... error 3021

    Dear Friends,

    Suppose I have 5 records in my database, I can delete 4 records without any error. But when I try to delete the last record, I am getting the following error: Error 3021 ..Either EOF or BOF is true....

    How to solve this problem?

    Margaret.

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: deleting problem ... error 3021

    Evidently if it wants to go to the next record after it deletes to last one. Without know what kind of database you have...

    cxn.execute "delete from table-name" will clear all the records without trying to read the next one.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    287

    Re: deleting problem ... error 3021

    Quote Originally Posted by Pasvorto
    Evidently if it wants to go to the next record after it deletes to last one. Without know what kind of database you have...

    cxn.execute "delete from table-name" will clear all the records without trying to read the next one.
    Hi,

    I am using Microsoft Access Database 2000. The following is the code:

    VB Code:
    1. Private Sub cmdDelete_Click()
    2. cmdDelete.Enabled = False
    3. Dim ano As String
    4. ano = MsgBox("Really delete !!! " + rs.Fields("Item") + "?", vbYesNo, "Comfirm Delete?")
    5. If ano = vbYes Then
    6. db.Execute "Delete from Deliveries where ID like " & rs(0)
    7. rs.Requery
    8. Show_Record
    9. Call Datagridcolumns
    10. End If
    11. cmdDelete.Enabled = True
    12. End Sub

    Margaret

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: deleting problem ... error 3021

    what were the IDs of the 5 records?

  5. #5
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: deleting problem ... error 3021

    Have you tried:

    rs.Requery
    if rs.recordcount > 0 then
    Show_Record
    ...
    endif

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: deleting problem ... error 3021

    Error Trap your delete routine.

    Even though you get the error message on record 5, has that record been deleted leaving your table empty?

  7. #7
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: deleting problem ... error 3021

    VB Code:
    1. Private Sub cmdDelete_Click()
    2. cmdDelete.Enabled = False
    3. Dim ano As String
    4. ano = MsgBox("Really delete !!! " + rs.Fields("Item") + "?", vbYesNo, "Comfirm Delete?")
    5. If ano = vbYes Then
    6. db.Execute "Delete from Deliveries where ID like " & rs(0)
    7. rs.Requery
    8. If Not rs.EOF Then
    9.     Show_Record
    10.     Call Datagridcolumns
    11.     cmdDelete.Enabled = True
    12. End If
    13. End If
    14. End Sub
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    287

    Re: deleting problem ... error 3021

    Hi,

    Pradeep, thanks for the help. It works supurb now.

    Regards,

    Margaret.

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