View Full Version : I want to eliminate the ugly error message when I skip ahead too far with a macro...


Accipiter22
09-27-2005, 11:24 AM
I'm going to try to be as blunt as possible...I'm having a devil of a time figuring this out..
alright, I've got a simple macro, called Ahead10, it uses the GoToRecord command, and for the offset I entered 10. I have a form i'm using this macro in. I made a button and attached the macro to it under the 'onclick event'. Now say there's 37 records in the form, I hit the button 3 times, and that takes me to record 31. But if I hit the button once more, I get an ugly 'action failed' dialogue box,becuase there's only 37 records, the action failed box looks unproffesional. I want to edit the macro so that if I hit the button and it would take me past the last record of the form instead of displaying that ugly error message, it just tells me 'not enough records to skip this far' or something of that ilk. But I don't know what commands to use under Access's macro editor to do this Any help would be appreciated.

Thanks!

matt

ghudson
09-27-2005, 02:15 PM
Welcome to the forum.

You need to dump the macros and start using VBA. VBA allows you to trap errors and handle them when they happen.

You can convert your macro to VBA [search the forum or Access help if you do not know how to do it] and work on how to count the number of records in the record source. Then stop the action of the jump if it exceeds the total number of records or better yet just go to the last record.

All of the above has been mentioned in many threads. Just use the forums advanced search function to find the answers to your problem.

Post back in the appropriate forum when you need more help.