Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: subhankar pandey
  Where is subhankar pandey?
 Kolkata/Delhi
 India
 subhankar pandey
 Tags
Subject: RE: Same Record is displaying
Thread ID: 154517 Message ID: 154782 # Views: 1 # Ratings: 1
Version: Visual FoxPro 8 Category: Reports and Printers
Date: Wednesday, December 19, 2007 2:16:35 PM         
   


> As per yr advise I hv set the following SQL in my prg file i.e.
> 
> clear all
> use partyname
> use debitnote
> 
> SELECT partyname.P_name, partyname.address1, partyname.address2, debitnote.denitnoten, debitnote.blno, debitnote.mv ;
>     FROM partyname  ;
>     INNER JOIN debitnote ON partyname.record_id = debitnote.record_id ;     
>     ORDER BY partyname.p_name ;
>     INTO CURSOR MyReportCursor
> 

> Now, How do I manipulate the cursor fields in my "MyReport" with the code
 REPORT FORM MyReport TO PRINTER PROMPT PREVIEW 

>
> Regards
> Subhankar
>

In your report, go into the dataenvironment and bring up the properties sheet. Check the .InitialSelectedAlias property and make sure that it is MyReportCursor rather than one of the tables. Now, close the data environment and double click each field in turn. When you get the field properies, change the table alias from PartyName or DebitNote to MyReportCursor. (Note - it is a lot simpler when you create the report from scratch. Run your SELECT command in the Command window and then you can simply use the columns in MyReportCursor when you create your report fields.)

Note also the following:

use partyname && opens PartyName in the current work area
use debitnote && closes PartyName and then opens DebitNote in the current work area


You end up with only one table open. If you wish to open two tables you need two work areas:

SELECT 0 && Get the next open work area
USE PartyName
SELECT 0 && Get another open work area
USE DebitNote
*** or better still, 
USE PartyName IN 0 SHARED && Opens PartyName shared in the next un-used work area
USE DebitNote IN 0 SHARED && Opens DebitNote shared in the next un-used work area


Then again, you are using a SELECT statement, so you do not need to USE these tables first. Try the following in the command window:

CLOSE TABLES ALL  && close all tables and you will start in work area 1

USE PartyName IN 0 SHARED && Opens PartyName shared in the next un-used work area
?SELECT([PartyName]) && Returns work area 1

USE DebitNote IN 0 SHARED && Opens DebitNote shared in the next un-used work area
?SELECT([DebitNote]) && Returns work area 2

SELECT partyname.P_name, partyname.address1, partyname.address2, ;
       debitnote.denitnoten, debitnote.blno, ebitnote.mv ;
    FROM partyname  ;
    INNER JOIN debitnote ON partyname.record_id = debitnote.record_id ;     
    ORDER BY partyname.p_name ;
    INTO CURSOR MyReportCursor
?SELECT([MyReportCursor]) && Returns work area 5 !!!!!


When your SELECT command is run, VFP opens the tables it needs using its own aliases. It is as if your SELECT command issued a USE PartyName IN 0 SHARED AGAIN. In your query, you have two tables. VFP therefore reopens PartyName again (using its own alias) in work area 3 and DebitNote (again with its own alias) in work area 4. When the resulting MyReportCursor is opened, it must therefore be opened in work area 5.

All of this is to say that you don't really need those two USE commands. This is why your program still works, even though your second command closes PartyName.

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

Same Record is displaying Posted by subhankar pandey @ 12/17/2007 1:17:41 PM
RE: Same Record is displaying Posted by Jojo Sabino @ 12/17/2007 2:07:02 PM
RE: Same Record is displaying Posted by Vladimir Zhuravlev @ 12/17/2007 2:11:18 PM
RE: Same Record is displaying Posted by Ken Murphy @ 12/17/2007 2:49:56 PM
RE: Same Record is displaying Posted by subhankar pandey @ 12/19/2007 5:48:06 AM
RE: Same Record is displaying Posted by subhankar pandey @ 12/19/2007 8:00:42 AM
RE: Same Record is displaying Posted by Ken Murphy @ 12/19/2007 2:16:35 PM
RE: Same Record is displaying Posted by subhankar pandey @ 12/20/2007 7:35:01 AM
RE: Same Record is displaying Posted by Ken Murphy @ 12/20/2007 1:40:12 PM