struggling to get the right message popups for correct and incorrect entries

PlasticMonster

Registered User.
Local time
Today, 18:37
Joined
Aug 21, 2012
Messages
30
I am trying to get the message Request added :) to show up when the new record command works.

The message "add button error" show if there are any errors, rather than just doing nothing and stopping.

However when it works I get both, I know I doing something very simple very wrong.

Private Sub bAddRecord_Click()
On Error GoTo errorhandler
RunCommand acCmdRecordsGoToNew
MsgBox "Request added :)"
On Error GoTo 0
errorhandler:
MsgBox "add button error"
End Sub

10 points to the first person to tell me why im an idiot. :banghead: Please...My project is so close after weeks and this is one of the last fidly silly little problems left.
 
Private Sub bAddRecord_Click()
On Error GoTo errorhandler
RunCommand acCmdRecordsGoToNew
MsgBox "Request added :)"
On Error GoTo 0
errorhandler:
MsgBox "add button error"
End Sub
i'm still pretty new to all this as well, but looking through my code and the way it's laid out, could this fix it?

my guess, which could very well be incorrect, is that without the addition of the "error_exit" procedure and a call to it after the error message is displayed, the program continues running down the bAddRecord_Click code, instead of stopping after the error message is displayed.

Code:
Private Sub bAddRecord_Click()
On Error GoTo errorhandler
 RunCommand acCmdRecordsGoToNew
 MsgBox "Request added "
On Error GoTo 0
error_exit:
 Exit Sub
errorhandler:
 MsgBox "add button error"
 Resume error_exit
End Sub
 
Hi

You wouldn't really need the 'on Error GoTo 0' because you are already set up to go to ErrorHandler. By going to 0, you are actually skipping the ErrorHandler set.

You would need the 'Exit Sub' before the error handling to bypass as mentioned already :)

Nigel

Sent from my OMNIA7 using Board Express
 
Previously id been tring to use cancel=true to stop the code but I needed exit sub :)

All working perfectly now
 

Users who are viewing this thread

Back
Top Bottom