Navigate next & previous in ND6 Client

I use two buttons with two standard "@Command"s:

@Command([NavigatePrevMain]) and

@Command([NavigateNextMain])

It works fine with the previous button (I can hit the back button many times till there are no documents in that direction, then I get an alert), but when I hit the next button till all documents are passed I’m kicked out of the application.

How can I control this problem?

Subject: NavigateNextMain: Databse closes after clicking button in last document

I actually have the same problem. I was trying to use getLastDocument, but it only gets the latest one in terms of date rather than in alphabetical order. Is there a way around this?