Code Error? 
Author Message
 Code Error?

The following code causes A2K to crash:

Dim rpt As Report
DoCmd.OpenReport strReportName, acViewDesign
Set rpt = Reports(strReportName)
rpt.RecordSource = strQueryName

The above code simply seeks to change the report's
recordsource.

The error dialog says Microsoft Visual C++ Runtime
Library Access.Exe abnormal program termination.

What's wrong please?
TIA
Geoff



Fri, 04 Mar 2005 22:10:33 GMT  
 Code Error?
It may be the same problem as posted in the thread "Set Row Source after

2002 22:12 (my date/time GMT + 10:00).

--
HTH
Van T. Dinh
MVP (Access)


Quote:
> The following code causes A2K to crash:

> Dim rpt As Report
> DoCmd.OpenReport strReportName, acViewDesign
> Set rpt = Reports(strReportName)
> rpt.RecordSource = strQueryName

> The above code simply seeks to change the report's
> recordsource.

> The error dialog says Microsoft Visual C++ Runtime
> Library Access.Exe abnormal program termination.

> What's wrong please?
> TIA
> Geoff



Fri, 04 Mar 2005 22:50:22 GMT  
 Code Error?
It appears not to be a speed issue.
I set a breakpoint on the line:
rpt.RecordSource = strQueryName
to give time for the report to open.
A2K continues to crash.

Geoff



Sat, 05 Mar 2005 01:59:08 GMT  
 Code Error?
Not 100% sure but I got a feeling that on breakpoint, everything stops so
the Form opening is stopped as well.  Try DoEvents as I suggested in the
other thread.

--
HTH
Van T. Dinh
MVP (Access)


Quote:
> It appears not to be a speed issue.
> I set a breakpoint on the line:
> rpt.RecordSource = strQueryName
> to give time for the report to open.
> A2K continues to crash.

> Geoff



Sat, 05 Mar 2005 06:52:10 GMT  
 Code Error?
Many thanks for your help.

I assumed the breakpoint had allowed the report
to open because I had an icon for the report on the
taskbar and could switch to the open report before
executing the codeline that caused A2K to crash.

I have moved on to another solution to my problem
and now can't quite replicate the original problem.
But I tested DoEvents as best I could, as you
suggested, and it may well have fixed the problem.

For anyone interested, I decided to abandon
changing the recordsource property of the report. This
created a clumsy visible user interface, which I did not
know how to suppress.  I had to open the report in design
view, change the recordsource property, close and
save the report, and open it again to print it.

My current approach is not to change the recordsource
property of the report.  Instead, I'm opening the report's
recordsource (a query) as a querydef object and changing
its SQL statement.  This works fine and the user sees
nothing.

I have no idea if this is the best approach, but for now,
it seems I'm home and dry.

Thanks again.
Geoff



Sat, 05 Mar 2005 16:28:28 GMT  
 Code Error?
Your solution sounds fine.

Just FYI, you can use the Echo method to stop the screen refresh so that the
user doesn't see what you don't want him/her to see.

--
HTH
Van T. Dinh
MVP (Access)


Quote:
> Many thanks for your help.

> I assumed the breakpoint had allowed the report
> to open because I had an icon for the report on the
> taskbar and could switch to the open report before
> executing the codeline that caused A2K to crash.

> I have moved on to another solution to my problem
> and now can't quite replicate the original problem.
> But I tested DoEvents as best I could, as you
> suggested, and it may well have fixed the problem.

> For anyone interested, I decided to abandon
> changing the recordsource property of the report. This
> created a clumsy visible user interface, which I did not
> know how to suppress.  I had to open the report in design
> view, change the recordsource property, close and
> save the report, and open it again to print it.

> My current approach is not to change the recordsource
> property of the report.  Instead, I'm opening the report's
> recordsource (a query) as a querydef object and changing
> its SQL statement.  This works fine and the user sees
> nothing.

> I have no idea if this is the best approach, but for now,
> it seems I'm home and dry.

> Thanks again.
> Geoff



Sat, 05 Mar 2005 20:49:56 GMT  
 Code Error?
Many thanks.  I didn't know that.
Geoff


Sat, 05 Mar 2005 21:30:47 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Code error w/o an error

2. Code Error(-2147023170) Automation Error

3. code error on transfer file

4. VB Code - Errors without debugging option?

5. Code Error

6. Coding Error - Please help find

7. Code errors

8. MDE code errors

9. Code-error

10. Getz code error/setting printer info

11. Changing Printers (was Re: Getz code error/setting printer info)

12. Why does this code Error on NEXT line?

 

 
Powered by phpBB® Forum Software