'Run Time error 2015' (1 Viewer)

KelMcc

Rock n' Roll Paddy
Local time
Yesterday, 21:02
Joined
May 23, 2002
Messages
97
OK, I get this error in 2 different circumstances (so far) in some of my various forms. That said, I wouldn't be surprised if they are fixed the same way or have the same root cause.

Circumstance 1
I have a form w/ a combo box and buttons. You select the person who's records you want from the combo box and then click the button for the form that you want to see w/ this person's records....

What happens?
A. If you select someone who exists, you get just there records. That's fine, that's what I want.
B. If you leave the combo box blank you get everyone's records. This is also fine.
C. You mistype a name or type in a name that has not records associated with it? You get the 'Runtime 2015' error.

I know I could fix this by using a list box, but then they wouldn't be able to see all the records like they can on option B. I'm hopeful there's a small pieces of syntax I can just put in there to prevent this?


Circumstance 2
Very similar... I have a form that opens a sub-form. The sub-form is set up to list the records from last to first (numerically).

What happens?
A. The main form record has sub-records that match and thus the sub-form displays them, starting with the last one and counting down. Like it would start on 5 you slide down to 1. Perfect.
B. The main form record has zero records in the table that the sub-form is referencing. You get the 'Runtime 2015' error..

When I don't sort from back to front, I never get this error. I'm sure that, like Circumstance 1, its expecting to find something and generates this error when it finds nothing.

So, hopefully the answer to this question is the same for both circumstances.

Thanks for whatever assistance you can provide.
 

dynamictiger

Registered User.
Local time
Today, 05:02
Joined
Feb 3, 2002
Messages
270
This is an error caused by trying to go past the end of the recordset. The simplest way to fix this is to add some error handling to your code. If you haven't got to the point of writing error handlers, you could cheat until you learn how by typing On Error Resume Next.

HTH
 

dgm

Registered User.
Local time
Today, 14:02
Joined
Sep 5, 2002
Messages
146
Could you post the code behind your buttons? Might help in finding the problem.

Dave
 

KelMcc

Rock n' Roll Paddy
Local time
Yesterday, 21:02
Joined
May 23, 2002
Messages
97
DQM, there's not much code there:

-----
Private Sub FISIFCommentE_Enter()
DoCmd.GoToRecord , , acLast
End Sub
-----

So, "FISIFCommentE" is called (source object is FISIFCommentRO) and it tries to go to the last record, BUT, there are no records so I get the 2015 error. This is the instance where FISIFCommentE is a sub-form.

Dynamic Tiger, the "On Error Resume Next" seems to have fixed it, at least in one of my examples. Thanks so much. :)

*does cartwheel*
 

Users who are viewing this thread

Top Bottom