Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21264

Run-time Error '3021': Either BOF or EOF is True

$
0
0
Name:  Untitled-1_zpsa289ecff.jpg
Views: 19
Size:  67.0 KB

My program is a simple inventory system. It has a 3 main form which are Main,Add and Edit form
Error: Every time I tried to select an item from the listview and press the Edit it shows an error.

Things I did before I get an Error;
* I change the Field Name order of the Database from IDNumber(Primary Key)-Owner-Status-Department-Acquired-Released into Owner(Primary Key)-IDNumber
* I did check the column header order of Listview on its properties. And I think its fine
* I did check the codes of modules and I think its fine
* And also I did check the codes of Edit form and I think it is also fine.

Please help me.
Here are the codes for Main and for Edit form and also for the Module

Main Form
Private Sub refreshDataSearch Code:
  1. Private Sub refreshDataSearch()
  2. Dim Itmx As ListItem
  3. EmployeeMain.Listview.ListItems.Clear
  4. While Not FindRs.EOF = True
  5. Set Itmx = EmployeeMain.Listview.ListItems.Add(, , FindRs.Fields("Owner"))
  6. Itmx.SubItems(1) = FindRs.Fields("IDNumber")
  7. Itmx.SubItems(2) = FindRs.Fields("Status")
  8. Itmx.SubItems(3) = FindRs.Fields("Department")
  9. Itmx.SubItems(4) = FindRs.Fields("Acquired")
  10. Itmx.SubItems(5) = FindRs.Fields("Released")
  11. FindRs.MoveNext
  12. Wend
  13. End Sub
Private Sub editite_Click Code:
  1. Private Sub editid_Click()
  2. If txtMonitor.Text = vbNullString Then
  3. MsgBox "Have you selected I.D. from Catalog? ", vbExclamation, "Edit an I.D."
  4. Exit Sub:
  5. End If
  6. EmployeeUpdate.txtIDNumber.Enabled = False
  7. EmployeeUpdate.txtIDNumber.Text = Me.txtMonitor.Text
  8. EmployeeUpdate.Show vbModal
  9. End Sub

Edit/Update Form
Private Sub Form_Activate Code:
  1. Private Sub Form_Activate()
  2. FindRecordset "Select * From Finder Where Owner = '" & txtOwner & "';"
  3. If Not FindRs.BOF = True Or FindRs.EOF = True Then
  4. txtIDNumber.Text = FindRs.Fields("IDNumber")
  5. txtAcquired.Text = FindRs.Fields("Acquired")
  6. txtReleased.Text = FindRs.Fields("Released")
  7. cboDepartment.Text = FindRs.Fields("Department")
  8. cboStatus.Text = FindRs.Fields("Status")
  9. Else
  10. End If
  11. End Sub
Private Sub cmdUpdate_Click Code:
  1. Private Sub cmdUpdate_Click()
  2. On Error GoTo errorupdate
  3. If txtOwner.Text = vbNullString Or txtIDNumber.Text = vbNullString Or cboStatus.ListIndex = -1 Then
  4. MsgBox "Please fill the required fields in order to save.", vbExclamation, "Saving Status"
  5. Exit Sub:
  6. End If
  7. executeQuery "UPDATE Finder SET Owner = '" & txtOwner & "', Acquired = '" & txtAcquired & "', Released = '" & txtReleased & "', Department = '" & cboDepartment & "', Status = '" & cboStatus & "' WHERE IDNumber = '" & txtIDNumber & "';"
  8. MsgBox "I.D. successfully Updated.", vbInformation, "Update Success"
  9. Call ClearAll
  10. Unload Me
  11. Call RefreshListview
  12. Exit Sub:
  13. errorupdate:
  14. MsgBox Error.Description, vbExclamation, "Error"
  15. Set FindCon = Nothing
  16. Set FindRs = Nothing
  17. End
  18. End Sub

Whole Codes for Module
Public Code:
  1. Public FindCon As ADODB.Connection
  2. Public FindRs As ADODB.Recordset
  3. Public Sub openCon()
  4. Set FindCon = New ADODB.Connection
  5. FindCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\Personnel.mdb;"
  6. FindCon.Open
  7. End Sub
Public Sub executeQuery(ByVal sql As String) Code:
  1. Public Sub executeQuery(ByVal sql As String)
  2. On Error GoTo errorcon
  3. Set FindCon = New ADODB.Connection
  4. If FindCon.State = adStateOpen Then
  5. FindCon.Close
  6. End If
  7. openCon
  8. FindCon.Execute sql, adOpenDynamic, adCmdText
  9. Exit Sub:
  10. errorcon:
  11. MsgBox Error.Description, vbCritical, "Error"
  12. Set FindCon = Nothing
  13. End
  14. End Sub
Public Sub FindRecordset(ByVal query As String) Code:
  1. Public Sub FindRecordset(ByVal query As String)
  2. On Error GoTo errorrs
  3. Set FindRs = New ADODB.Recordset
  4. If FindRs.State = adStateOpen Then
  5. FindRs.Close
  6. End If
  7. openCon
  8. FindRs.Open query, FindCon, adOpenDynamic, adLockOptimistic
  9. Exit Sub:
  10. errorrs:
  11. MsgBox Error.Description, vbCritical, "Error"
  12. Set FindRs = Nothing
  13. End
  14. End Sub
Public Sub Public Sub RefreshListview Code:
  1. Public Sub RefreshListview()
  2. Dim Itmx As ListItem
  3. FindRecordset "Select * From Finder Order By IDNumber"
  4. EmployeeMain.Listview.ListItems.Clear
  5. While Not FindRs.EOF = True
  6. Set Itmx = EmployeeMain.Listview.ListItems.Add(, , FindRs.Fields("Owner"))
  7. Itmx.SubItems(1) = FindRs.Fields("IDNumber")
  8. Itmx.SubItems(2) = FindRs.Fields("Status")
  9. Itmx.SubItems(3) = FindRs.Fields("Department")
  10. Itmx.SubItems(4) = FindRs.Fields("Acquired")
  11. Itmx.SubItems(5) = FindRs.Fields("Released")
  12. FindRs.MoveNext
  13. Wend
  14. End Sub

Please help me :(
Its part of my Thesis. Thank thank thank thank you soo much!
Attached Images
 

Viewing all articles
Browse latest Browse all 21264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>