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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem in printing the last record

Status
Not open for further replies.

zhed0708

IS-IT--Management
Jun 25, 2011
41
PH
i'am having problem in printing my report. i want to print the last record that was save in the table..my code is here:

IF NOT EOF() AND NOT BOF()
currentRecord = RECNO()
REPORT FORM renew FOR RECNO() = currentRecord TO PRINT PREVIEW
ENDIF

but when i print the last record i save, my report does not display. it will just flash and return to my form...plz help me...thanx...
 
First, lets look at your code.

Code:
IF NOT EOF() AND NOT BOF()
    currentRecord = RECNO()
    REPORT FORM renew FOR RECNO() = currentRecord TO PRINT PREVIEW
ENDIF

If you are already 'sitting on' the record that you want to print then you don't need to do all that.

Code:
* -- Print Next 1 Record - begin counting from current record --
REPORT FORM renew NEXT 1 PREVIEW NOCONSOLE

When you get a Report Form 'flashing' there is generally a problem with the Report Form not finding something that it needs to display itself.

While in the VFP Development mode:
1. USE your data table (open it)
2. Type MODIFY REPORT renew (open Report Form for editing)
3. From VFP top menu - View - Preview
If everything the Report Form needs is present, the Preview will be displayed.
If not, this will generally cause the problem to be displayed

Good Luck,
JRB-Bldr

 
By the way, there's another thread here which looks like it deals with a similar issue: thread184-1658763

I haven't read that thread in detail, so I'm not sure how relevant it is. But it might be worth a look.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
JRB-Bldr,,..

sir, my report is displayed when i print preview it but when i run my form and print the record, my report does not displayed...

here's my code..

WITH thisform
SELECT transaction
APPEND BLANK
replace name WITH thisform.txtname.Value
replace address WITH thisform.combo5.Value
replace date WITH thisform.txtdate.Value
replace dateissued WITH thisform.txtdateissued.Value
replace ctcnum WITH VAL(thisform.txtctcnum.Value)
replace ornum WITH thisform.txtornum.Value
replace payment WITH thisform.txtpayment.Value
replace purpose WITH thisform.combo3.Value
replace bname WITH thisform.txtbname.Value
this.Refresh()

REPORT FORM renew NEXT 1 PREVIEW NOCONSOLE
thisform.release ()
endwith

first i save the record and automatic prints the last record...what is the problem here? help me!....plz....



zhed
 
first i save the record and automatic prints the last record

So what's the problem?

Originally you said that your Report did not appear on-screen, but instead 'flashed' and then was gone.

Is that still the problem?

If so, have you done as I suggested above to test if some piece of information is missing that the Report Form needs?

The command you used:
REPORT FORM renew NEXT 1 PREVIEW NOCONSOLE
has the option NEXT 1 which means 'print 1 record'
And the previous command APPEND BLANK automatically points the record pointer to the last record.

So you were telling the program to print the last record only of the data table - transaction.

Let us know.

Good Luck,
JRB-Bldr



 
PREVIEW displays on the console, NOCONSOLE says not to put anything on the console.

Which is it?

Also, you've now posted two entirely different REPORT FORM commands. Which is it?
 
Dan - that's not exactly correct.

According to the VFP Help file:
NOCONSOLE
Suppresses the echoing of a report to the main Visual FoxPro window or to a user-defined window when the report is being printed or sent to a file.


You can indeed use NOCONSOLE in conjunction PREVIEW (or without PREVIEW) since it suppresses the 'echo' output to the Visual Foxpro main console 'window'.
It does not suppress the primary output to the Report Form's Preview window.

It may not be necessary to use, but it hasn't seemed to be a problem for the many times I have used:
REPORT FORM (cReportForm) NOCONSOLE PREVIEW
It has worked fine for my clients for many years.

zhed0708 - Good Luck,
JRB-Bldr

 
Hi

your code:
Code:
WITH thisform
SELECT transaction
APPEND BLANK
    replace name WITH thisform.txtname.Value
    replace address WITH thisform.combo5.Value
    replace date WITH thisform.txtdate.Value
    replace dateissued WITH thisform.txtdateissued.Value
    replace ctcnum WITH VAL(thisform.txtctcnum.Value)
    replace ornum WITH thisform.txtornum.Value
    replace payment WITH thisform.txtpayment.Value
    replace purpose WITH thisform.combo3.Value
    replace bname WITH thisform.txtbname.Value
    this.Refresh()

REPORT FORM renew NEXT 1 PREVIEW NOCONSOLE
thisform.release ()
endwith
Has a lot of Thisform which can be avoided, made shorter.
So also should work:
Code:
With Thisform
	Select Transaction
	Append Blank
	Replace Name With .txtname.Value , ;
		address With .combo5.Value, ;
		Date With .txtdate.Value, ;
		dateissued With .txtdateissued.Value, ;
		ctcnum With Val(.txtctcnum.Value), ;
		ornum With .txtornum.Value, ;
		Payment With .txtpayment.Value, ;
		purpose With .combo3.DisplayValue, ;
		bname With .txtbname.Value

	Report Form renew Next 1 Preview Noconsole
EndWith
ThisForm.Release ()
Jockey(2)
 
Jockey,

You're right that Zhed's code can be made more compact and more efficient. But it's got nothing to do with the problem that we are struggling to help Zhed to solve. Perhaps it would be better to focus on finding a solution, and then worry about the verbosity of the code.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
sir jrbbldr....

sir, i already tried your suggestion and it is doing fine..my report peviews..then i used your code " REPORT FORM renew NEXT 1 PREVIEW NOCONSOLE " and it is good. It also previews my report but i noticed that my report previews only one (1) record. i checked my table transaction but there are lot of records there. how come that it previews different from the last record i save?

is it my code the problem or my report?

zhed
 
Zhed,

You said: i noticed that my report previews only one (1) record..

That's why we suggested you add NEXT 1 to the command. NEXT 1 tells it to show the next one record (including the one you are sitting on). Isn't that what you wanted?

how come that it previews different from the last record i save?

If you do an APPEND BLANK, then immediately preview the report, the report should show the record you just appended. Are you now saying that's not the case?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
sir MikeLewis....

sorry for wrong statement in " noticed that my report previews only one (1) record.."

it should be different from the last record i save...
sir,,you are correct..my report does not preview the last record i save instead he got the record somewhere at the database..once i run my application and print my report, it always prints preview the record but not the record i save.it prints the same record..

zhed
 
OK, Zhed, so it sounds like a problem with the positioning of the record.

Does the record contain some kind of unique identifier, such as a transaction number or ID of some kind?

If so, try this.

1. Let's say the unique ID field is named TransactionNum.

2. At the time that you do the APPEND BLANK, store a copy of the unique ID in a variable, named, say lcTransactionNum.

3. Change your REPORT FORM command. Take out NEXT 1, and in its place put: FOR TransactionNum = lcTransactionNum.

Let us know if that works or not.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
it should be different from the last record i save...

Your data table record pointer will always be on the last record you save
* no matter if that save was with an APPEND BLANK followed by REPLACE....
* or it was just locate a record and then REPLACE....
unless you do something to move it elsewhere.

If you want to print the data from another record, you will need to put some code into your application just prior to your REPORT FORM command to move the record pointer to where you want it.

You can do that, or its equivalent, in a number of ways.
1. As Mike suggests above - use the FOR option in your REPORT FORM command.
2. Create a temporary cursor with only the data you need for reporting.
Code:
   * Example:
   * --- Get temporary copy of desired record into temp cursor ---
    SELECT *;
     FROM transaction;
     WHERE <whatever criteria you need>;
     INTO CURSOR RptData
    
    * --- Print just this data ---
    SELECT RptData
    REPORT FORM renew PREVIEW NOCONSOLE
    SELECT RptData
    USE
3. Move the record pointer in your primary table
Code:
   * Example:
   * --- Move record pointer in primary table ---
   SELECT Transaction
   LOCATE FOR <whatever criteria you need>
   REPORT FORM renew NEXT 1 PREVIEW NOCONSOLE
One caution with this is that your User Form could possibly need data from the original record after the REPORT FORM command and that is no longer the current record - so be careful.

Good Luck,
JRB-Bldr
 
Not reading through all this, I would recommend you also take a look into the data environment of the report. A report can only be controlled from outside if it's dataenvironment does not change the selected alias to something it opens itself. All Scope clauses have no effect then.

Bye, Olaf.
 
sir.....

i get the problem for my report...it is not in my code but in my report form. the fields in my table in the data environment i use has the problem. i deleted the fields i use in my report then repeat adding it...


zhed
 
yes sir,....the problem is in my report sir...thanx all for your help and for the others that was helping me here. this site was so helpful..keep it up... god bless....

zhed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top