Access 2002 questions

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hello I have two questions for Access 2002, I am trying to
set a breakpoint in a forms code, for some reason the
breakpoint is never reached even though the code
executes. Has any one had this happen. I would include
the code but it happens to any code that I set the
breakpoint.
Second, I was getting the Error 2001 (You canceled the
previous operation) when there is nothing wrong. Is this
a bug in Access? I get the error when I open a report in
the Preview (acPreviewState) state. I don't have this
problem when I printout the report. I would include the
code for this problem, but it compiles with no errors.
Also I have the Option Explicit option so I have to
declare all of my variables.
Any ideas. Thanks.
Mark
 
In respect to your breakpoint, something is causing your code not to
execute, i.e., a bad error handler. For example,

Sub Main()

On error resume next

DoSomething

End Sub


Sub DoSomething()

Dim x as object
Dim a As integer, Dim b as integer, dim c as integer

Set x = CreateObject("Unregistered.Application")

c = a + b 'Put breakpoint here

End Sub


If a breakpoint is placed where indicated, it will never be reached because
there is no error handler in DoSomething...so, the error is handled by Main.
You would need to step through DoSomething to see that an error occurs at
Set x = CreateObject("Unregistered.Application").


The parameter for opening a report in Preview mode is acViewPreview...not
acPreviewState. Post your code anyway.
 
Mark-

1) Make sure that you leave the form's module (where you set the breakpoint)
open in the VBE window. I recently discovered some interesting bugs related
to the debugger not halting unless the module (or the module that called the
module) is open in VBE. Are you certain that the code is running? Did you
put a MsgBox or a Debug.Print in the code to be sure you're getting to the
halt?

2) You get the Cancel error in a DoCmd.OpenReport if you have code in the
report's NoData event that cancels the open. I think you can also get it if
the user hits Ctrl-Break while a page is still formatting. You could try
trapping the error and inserting a Stop to halt the code. Examine the call
stack to see what is signalling the error.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
http://www.deanforamerica.com/site/TR?pg=personal&fr_id=1090&px=1434411
 
Back
Top