Trap the automatic message box for a button

Juan

Registered User.
Local time
Today, 04:27
Joined
Feb 16, 2006
Messages
32
Hi everyone

I posted this question about an hour ago but I seem to have been logged out by the time that I actually pressed "send", so I don't know whether it was posted correctly - I can't find it!

I've created four buttons on a form to negotiate my way through the records. When I come to the end, a message box is shown stating that the next record cannot be found (it doesn't exist). Can I trap this message and use it to activate some code? I thought about a form popping up (in "corporate" colours to match the remainder of the database) or a form asking whether I want to add another record.

I looked at the code that Access generated when I made the buttons, and I saw the following:

Err_MyButton_Click:
MsgBox Err.Description
Resume Exit_MyButton_Click

I "remmed" out the middle line, but the automatic message box still appeared. I added a line of code: <MsgBox Err.Number>, but that didn't give a result, so I guess that the message box that's being shown isn't generated via this snippet of code.

I know that I could disable the relevant button when the record number reaches the end or add another button to add a new record, but I'd like to trap this automatic message box. Can I do so, and, if so, how?

Thanks for your time.
 
Last edited:
I managed a workaround - I don't know how efficient it is, but it works. I checked the current record number. If it's 1 or the maximum number of records in the table, it jumps to some code to add a new record. The reason that I check for 1 or max is because I have records displayed in reverse order in some forms.

Maybe someone else will need to do this some day and will use this approach - or someone may know a more efficient way.

Juan
 

Users who are viewing this thread

Back
Top Bottom