Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / August 2005



Tip: Looking for answers? Try searching our database.

error 3021 error handling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pb - 29 Aug 2005 21:48 GMT
I get the "Either BOF or EOF is true, or current record has been deleted.
Requested operation requires a current record." when i have loaded a listview
with records on a form. Happens when i double click on the Listview or click
the command button EDIT, which edits the record. I get it because the ms
access db is empty.  I'm looking for some error handling to let the program
know that no records have been returned.

'''ADO connection COde:
Public sub connectDatabase()
Set rsTransactions = New ADODB.Recordset
rsTransactions.Open "TABLE1", cnBank, adOpenKeyset, adLockOptimistic
End Sub

'''Form1 Code:
Private Sub Form_Load()

Call connectDatabase
Call LoadListView(rsTransactions)

End Sub

Public Sub LoadListView(myRs As Recordset)
With myRs

While Not .EOF
lstItem.SubItems(1) = ![LAST NAME]
lstItem.SubItems(2) = ![FIRST NAME]

'lvwTransactions.ListItems.Add , , !CustomerID & " " & !AccountNo ' & " " &
!Narration & " " & !Dated & " " & !Debit & " " & !Credit
.MoveNext
Wend
End If

End Sub

Private Sub cmdEdit_Click()
With rsTransactions
.MoveFirst

While Not .EOF

If lvwTransactions.SelectedItem.ListSubItems(1) = !LASTNAME Then
'edit as needed
   .MoveLast
   .MoveNext
   Else
   .MoveNext
   End If
Wend

End With
End Sub

Private Sub lvwTransactions_ColumnClick(ByVal ColumnHeader As _
   MSComctlLib.ColumnHeader)
   ' Sort according to data in this column.

   If lvwTransactions.Sorted And _
       ColumnHeader.Index - 1 = lvwTransactions.SortKey Then
       ' Already sorted on this column, just invert the sort order.
       lvwTransactions.SortOrder = 1 - lvwTransactions.SortOrder
   Else
       lvwTransactions.SortOrder = lvwAscending
       lvwTransactions.SortKey = ColumnHeader.Index - 1
   End If
   lvwTransactions.Sorted = True  
End Sub
Mario G. - 30 Aug 2005 14:19 GMT
See code below.  If the recordset is empty you cannot call the .MoveFirst
method.  I suspect that the error you are encountering is occuring here.  

Private Sub cmdEdit_Click()
With rsTransactions
   .MoveFirst <== Error is occurred here

   While Not .EOF
       If lvwTransactions.SelectedItem.ListSubItems(1) = !LASTNAME Then
           'edit as needed
           .MoveLast
           .MoveNext
       Else
           .MoveNext
       End If
   Wend

   End With
End Sub

MarioG

> I get the "Either BOF or EOF is true, or current record has been deleted.
> Requested operation requires a current record." when i have loaded a listview
[quoted text clipped - 64 lines]
>     lvwTransactions.Sorted = True  
> End Sub
pb - 30 Aug 2005 14:47 GMT
OK thanks...this seems to have fixed it:

On Error GoTo ErrorHandler
ErrorHandler:
If Err.Number = 3021 Then
MsgBox "No records are in the database"
Else

End If

> See code below.  If the recordset is empty you cannot call the .MoveFirst
> method.  I suspect that the error you are encountering is occuring here.  
[quoted text clipped - 86 lines]
> >     lvwTransactions.Sorted = True  
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.