Error Trapping

HockeyNut

Tureco Del Hockey
Local time
Today, 10:52
Joined
Feb 25, 2003
Messages
62
Error Trapping (probably for dummies)

Hi everyone,
I've been toiling with error trapping, having never used it before, and am struggling.
I think I'm missing something fundatmental and would like if anyone could look at my code to point out the (probably glaring to you) problem.

I've had a good look through lots of code on here as well as searching for information on it here. One post recommended looking under "error handling in run-time applications" in MS Access Help, but this give nothing for me. :(

I want it to come up with my error message, not the Access default error about "not in list".
At the moment it bring up my error msgbox, and then the access default one. :(

Here is my code, can anyone please advise? :confused:
------------------------------------------------------------------------------------------------
Private Sub cboTitle_NotInList(NewData As String, Response As Integer)
Call InvalidComboSelection
End Sub
------------------------------------------------------------------------------------------------
Private Sub InvalidComboSelection()
MsgBox "Please choose a valid option from the list provided", vbOKOnly, "Invalid selection"
'MsgBox "Put your message in here", msgbox type here, "msgbox title here"
End Sub
------------------------------------------------------------------------------------------------
 
As this is a form error you need to use the Response parameter to inform Access how the error has been handled.

What you want it to put the line:


Code:
Private Sub cboTitle_NotInList(NewData As String, Response As Integer) 
    Call InvalidComboSelection
    Response = acDataErrContinue
End Sub
 
Thanks a lot Mile.
I knew it'd be something blindingly obvious which I was missing/doing wrong. After spending a couple of hours this morning trying to work it out I decided to consult with the Forum as I knew it would be childs play to someone!

I wanted to do it slightly different. As I have a few combo's which call the same sub "InvalidComboSelection". It would be advantageous to me have the "Response = acDataErrContinue" in the sub. But when I tried this it wouldn't work. Do I need to go about it a different way to get this to work in the way that I want?

Thanks again,
HN
 
Should be able to just pass the parameter...

Code:
Private Sub cboTitle_NotInList(NewData As String, Response As Integer) 
    Call InvalidComboSelection 
End Sub 


Private Sub InvalidComboSelection(Response As Integer) 

    MsgBox "Please choose a valid option from the list provided", vbOKOnly, "Invalid selection"
    Response = acDateErrContinue

End Sub
 
I tried it that way and got an error in my code.

Compile Error:
Argument not optional

In my code it highlights the following line.

Call InvalidComboSelection

:confused:
 
Last edited:
Sorry...

Code:
Private Sub cboTitle_NotInList(NewData As String, Response As Integer) 
    Call InvalidComboSelection(Response)
End Sub 


Private Sub InvalidComboSelection(Response As Integer) 

    MsgBox "Please choose a valid option from the list provided", vbOKOnly, "Invalid selection"
    Response = acDateErrContinue

End Sub
 
Thanks for sticking with me on this Mile :)

I've tried it that way an it give a new compile error: "Variable not defined" and highlights the code which says "acDateErrContinue".
 
Try:

Private Sub InvalidComboSelection(ByRef Response As Integer)

I just tried it quickly and it worked fine.
 
lol, It's DataErrContinue ; Not DateErrContinue

I need to wake up - was out last night for the game. Not feeling good.
 
lol.
Thanks a million Mile :)

I missed the game... I was at my VB class ...not that you'd believe that with asking this question! :rolleyes: lol
 
Mile-O-Phile said:
lol, It's DataErrContinue ; Not DateErrContinue

I need to wake up - was out last night for the game. Not feeling good.
You ate pheasant, serves you right!
 

Users who are viewing this thread

Back
Top Bottom