Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error 3021 - rst.movelast 1

Status
Not open for further replies.

696796

Programmer
Joined
Aug 3, 2004
Messages
218
Location
GB
Hello,

I have a search function which is kicking out an "error 3021, no current record"

This is because no matching records were found. Now it highlights 'rst.MoveLast' in my code, which moves it to the last record but this obviously isn't working.

The rest of my code is as follows:-

Private Sub DESCRIP_AfterUpdate()

Me.Filter = "[IssueDescription] LIKE '*" & Me![DESCRIP] & "*'"
Me.FilterOn = True

Dim rst As DAO.Recordset

Set rst = Me.RecordsetClone
rst.MoveLast
MsgBox "Found " & rst.RecordCount & " Records"
Set rst = Nothing

End Sub

Is there another function available for me to use or way of trapping this error so that it doesn't crash!

Regards,

Alex Marchant
Systems Development Engineer
 
Hi

How about:-

Private Sub DESCRIP_AfterUpdate()

Me.Filter = "[IssueDescription] LIKE '*" & Me![DESCRIP] & "*'"
Me.FilterOn = True

Dim rst As DAO.Recordset

Set rst = Me.RecordsetClone
If RST.Recordcount > 0 Then
rst.MoveLast
MsgBox "Found " & rst.RecordCount & " Records"
Set rst = Nothing
Else
MsgBox "No matching Records
End if

End Sub


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Just for future reference, you might want to look into error handling... the format is something like:

private function blah()
on error goto lineError

some code...

end
lineError:
error handling code...
end function

you can also have more than 1 lineError: for different errors and stuff...
 
Sweeeet, yeah i need to start handeling/catching errors. Thanks for the advice, as ever, you've outdone youselves
 
I have to admit, I don't actually bother with error handling either... guess I should follow my own advice...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top