Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data environment is already loaded

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,827
JP
Hi all,
My debugging skills are very rusty these days, and I started working on a project that I haven't touched for many years. I went to do a Print Preview of a report that I have, and when I click my Print Preview button I get this error message:
Data environment is already loaded

The Click Event code reads:
Code:
SELECT MONSTER
lnScope = RECNO()
*
REPORT FORM MONSTER RECORD lnScope NOCONSOLE PREVIEW
*
GO lnScope

The init code on the button is just default. Maybe it's an obvious thing and I'm just out of practice.
Thanks!

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Yes, they are just set at Default. I have no code in them, and nothing inherited that I can see.

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Scott,

Have you checked the data environment of the report (not the form)?

Open the report in the Report Designer, and go to View / Data Environment. Then check the Data Environment page in the report's properties. There might be some conflict that's causing the message.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
I put a trace on, and stepped through the code.
When it hits the REPORT FORM line, as you say, that launches the Data Environment. It launches the Destroy event code in the Data Environment (which seems like an odd event to do at that moment?) which has"

THIS.OpenTables

Which is results in the offending line. Whit is odd, is I have another application that has the same code, and it works... so I'm not sure what is different. Any ideas?
-S

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Not sure why this is happening. But it would be worth removing the THIS.OpenTables, just to see the effect.

If that gets you passed the error, you might then see "variable not found" messages in the report (because the table that drives the report is not open). The solution might be not to use the data enviroment at all, but to open the driving table(s) in your code, before you launch the report.

As I say, I'm not sure about any of this, but it would worth a try.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike,
Thanks, that was my thinking too. The main reason I don't want to "stray" too much is, I have a number of apps that match the "pattern" of code, but it's been a long time since I wrote it, and I don't know why, I'm sure I'll dig that out eventually. If the other similar forms and reports didn't work the same way, I'd bypass it, but I know me well enough to know that when I was writing good systems, a change like this could break other things. But that said, I'm going to try to comment that line and see what happens. I'm sure there is something very subtle I'm missing somewhere.


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Well, that was a train wreck. :)
Crashed the whole application then, and as you said, complained about missing variable.

I might try just working with the report form, interactively using "preview" and prove I have a good working report form first. Will let you know what happens.


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Olaf,
What is that?


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
If your foxpro does not have it, forget it. There were improvements in the reportengine in VFP9, you can switch between old and new behavior with it. If you have VFP9 this might be a reason the report does not continue to work.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top