Am currently working with VB 6.0 and Win7 OS. My application is linked with Microsoft Access 2007 (2002-2003 file format) database and whenever I want to update a record in a table from the Access database the project will display a message "Run-time error '3021' Either BOF or EOF is true, or the current record has been deleted. Requested operation requires a current record."
The challenge I have is on line 10 that's where my project halts. Would there be any approach I can use to continue with my project. Below is the code for update procedure.
The challenge I have is on line 10 that's where my project halts. Would there be any approach I can use to continue with my project. Below is the code for update procedure.
Code:
Private Sub updateButton_Click()
If rs.State = adStateOpen Then rs.Close
Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\NDASS.mdb"
rs.Open "SELECT*FROM Details where RegNumber='" & txtSearch.Text & "'", _
Con, adOpenKeyset, adLockPessimistic
If rs.BOF Or rs.EOF = True Then
rs.update
txtRegNo.Text = rs![RegNumber]
txtSurname.Text = rs!Surname
txtMiddleName.Text = rs!MiddleName
txtOtherName.Text = rs!Othernames
cboDOB1.Text = rs!DOB1
cboDOB2.Text = rs!DOB2
cboDOB3.Text = rs!DOB3
imgPassport.Picture = LoadPicture(rs!Passport)
'
txtCivilianPersonnelName.Text = rs!CivilianPersonnelName
txtOffBusAddress.Text = rs!civilianOfficeBusinessAddress
txtEmailNDACivilian.Text = rs!CivilianEmail
txtPhoneNDACivilian.Text = rs!CivilianPhoneNumber
cboClassApplied.Text = rs!ClassApplied
cboSpecialDisability.Text = rs!SpecialDisability
'
rs.Update
MsgBox "Record updated!", vbOKOnly + vbInformation, "Modify"
End If
rs.Close
Set rs = Nothing
'
Con.Close
Set Con = Nothing
End Sub
Comment