Proper Practice: Running a report without disturbing data  
Author Message
Aleniko29139





PostPosted: Visual FoxPro General, Proper Practice: Running a report without disturbing data Top

I have created a class which contains a textbox to display an order#. I usually drop this class in a grid.
The double click of the textbox does something like this:

select tmpCpo
go top
set relation to cpono into cpo
select cpo
set relation to acct into Customer
select tmpCpo
report form cpo01 preview

How should I prevent disturbance to the current data 'status' when the user dblclicks on the instantiated object Basically I would like to restore my environment to what is was before the user initiated the report.

In the old 2.6 world this would be a hassle so I was wondering if new tools like the session class should be used in VFP9 in order to achieve this...

Thanks you all.




Visual FoxPro1  
 
 
Rick Schummer





PostPosted: Visual FoxPro General, Proper Practice: Running a report without disturbing data Top

You can use the Session object (create it before you open the tables and set your relations, and run the report). VFP will be doing more work taking this route.

My preference is to do run a SQL Select to create the report cursor. This way you do not need to set relations and not worry about the record pointers moving in the cursors you have on the form (or in your case the grid). All you have to do is save the current workarea number (using lnSelect = SELECT()), and restore it at the end of the method. Close the report cursor at the end of the method.