Log in

View Full Version : Solved: Unwanted Breakpoint



Trendstate
09-04-2008, 03:07 PM
Hey All,

I have a very odd error that i havent seen before and so far can find no help online.
A breakpoint occurs in the code the first time the code is run after loading. The break occurs without actually setting a burgendy breakpoint, and the code continues without error if you continue the run.

There is no error msg and the code runs fine every run after the first run.

Any assistance would be appreciated.

Cheers.

Mavyak
09-04-2008, 06:12 PM
We'll probably need to see the code in order to deduce the problem. Please post the entire procedure/function where the breakpoint is occurring.

asingh
09-05-2008, 09:55 PM
Same thing used to happen with me too once. The way I solved it.

Set another break point..ran the code once. Then removed all break points..resaved..!

Trendstate
09-08-2008, 04:10 PM
i tried your idea, asingh, adding and removing break points but it did not work.
i cut all code out of the module and placed it in a text editor and copied it back into a new module and it seems to have stopped the problem.
However, this error is infrequent and unpredictable so im not sure if the testing was just a series of lucky runs.

The Error occurs in the following code. Marked with @@@@@


Sub RunSQL(ByVal strSQL As String)
'Runs the sql against the database turning off the warnings
If ALLOW_ERRHANDLER = True Then On Error GoTo errHandler
'try catch for incorrect input handling such as inappropriate time frames

On Error GoTo errInputError '@@@@@@@
DoCmd.SetWarnings (False)
DoCmd.RunSQL (strSQL)
exit_Procedure:
DoCmd.SetWarnings (True)
Exit Sub
errHandler:
Call Error(Err.Number, Err.Description, Err.Source, "modCommon - Sub RunSQL(ByVal strSQL As String)")
Resume exit_Procedure
errInputError:
MsgBox "Incorrect Information given, please rerun with appropriate data"
Resume exit_Procedure
End Sub

Mavyak
09-08-2008, 04:48 PM
Why even test to see if ALLOW_ERRHANDLER is true or not to point errors to line label errHandler if in the very next line you're telling the compiler to go to line label errInputError when it encounters an error? It's kind of like taking an exit on a freeway that leads to the same freeway you are on. Should it be structured like this instead:
If ALLOW_ERRHANDLER Then
On Error Goto errHandler
Else
On Error Goto errInputError
End If

Trendstate
09-08-2008, 04:53 PM
This is true. thx