Re: recognize EOF condition when using GoToRecord Action



For many years, VB experts have specifically recommended that GoTo
never be used. Like Kill and Open, it is as carry-over from a by-gone
age, and inherently dangerous.

In Northwinds MS writes it own Function to handle GoToRecord errors,
such as trying to pass beyond EOF:

Function TryToGoToRecord(Record As AcRecord) As Boolean
On Error GoTo ErrorHandler

DoCmd.GoToRecord , , Record

Done:
Exit Function
ErrorHandler:
MsgBox Err.Description
Resume Done
End Function

But I think this is insufficient to handle the situation you are
describing. Regardless, I would recommend putting your code lines in
an error handling snippet, learning what error number arises on an EOF
error and doing some action when that error (number) occurs in your
error-handling block.

For even more advice than you want I may say that I discourage working
with recordsets except in very unusual conditions. We have beautiful
Access forms that allows us interaction with data. We have efficient
SQL that allows us to modify data painlessly and relatively safely.
And we have recordsets when we need to be slow, clumsy and vulnerable.

No, I don't hope to convert anyone. Obesity will disappear in North
America before the use of recordsets in inappropriate situations
disappears. But maybe there will be some newbie reading this who might
be influenced. I can hope.




On May 28, 10:08 am, MLH <C...@xxxxxxxxxxxxxx> wrote:
If I'm using the following in a procedure...

DoCmd.GoToRecord acDataForm, "FormName", acNext, 4

... how can I recognize the EOF condition? Using GoToRecord,
I find myself lost when trying to determine when EOF is reached.

I suppose it's too much to wish for something like...
On EOF GoTo Exit_Label

.



Relevant Pages