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

Wrong error being reported ?

Status
Not open for further replies.

DarrenWard

IS-IT--Management
Feb 15, 2002
217
GB
I have several reports that use the following function;

FUNC _np
_temp = son
skip
if eof() or son <> _temp
skip -1
return .t.
else
skip -1
return .f.
endif

Then set the PrintWhen property on the totals of the reports to _np(), this then only prints the totals on the last page of multi page documents.

The problem I get is when I run the code I get the following error on the skip line.

THISFORM can only be used within a method

If I Ignore the error the report prints correctly. I have tried moving the function and re-writing it, if there was a problem with it I cant understand the error type that is being reported.

I have run the code in vfp6.0 and vfp8.0 with the same problem, have called the function from different reports, any ideas?

Dazz GuiltyMaggot - The best rock band in the world!
 
DarrenWard

THISFORM can only be used within a method

Where is your method placed? In a form? How are you calling your method? Is there an actual that exists when thisform is issued?
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
thisform is not issued that is the thing, this is the code that calls the report is in a command button.

if thisform.cmboutput.listindex = 1
thisform.windowstate = 2
report form sys(5) + sys(2003) + _RPath + 'RP017' preview noconsole
else
report form sys(5) + sys(2003) + _RPath + 'RP017' to printer
endif

It is a straight forward report (sales quotation) with totals at the bottom, so use the func to only put the totals on the bottom of the last page.

VFP tells me that the SKIP command in the func is causing the error shown, it is not erroring on a THISFORM command!

It is driving me mad, same thing happens for sales orders, invoices, purchase orders etc. etc. GuiltyMaggot - The best rock band in the world!
 
DarrenWard

Where is the _np function stored, and where is it being called from? Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
The function was in a seperate loaded and named program file.

I have also tried putting it in the main program file with no difference.

GuiltyMaggot - The best rock band in the world!
 
DarrenWard

I would then surmise that if your function does not have a &quot;thisform&quot; in it, then the function is not the problem. Do you have a &quot;thisform&quot; anywhere in your report? (Sorry for that question, but without have the report with me I can only guess where the problem is). Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi mike,

I have been through the report and it does not have a thisform on it.

I do not understand it, it must be being generated from somewhere but just cannot find it.

GuiltyMaggot - The best rock band in the world!
 
DarrenWard

And unfortunately a &quot;SET STEP ON&quot; does not work with a report. But you could put it in your _np() function and see exactly what line causes the problem. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
It reports that the SKIP command is generating the error, but it must be in the form.

Im gonna start stripping stuff out of the form and see what happens.

GuiltyMaggot - The best rock band in the world!
 
DarrenWard

I also noticed that you are not specifying an alias for your SKIP, you may want to do that and also can I presume there is an ENDFUNC at the end of your function?
FUNC _np
_temp = son
select myTable
skip
if eof() or son <> _temp
skip -1
return .t.
else
skip -1
return .f.
endif
ENDFUNC
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
My report is totally bare know apart from one detail line, the SKIP command is causeing the error.

This there any other way of getting the total at the bottom of the page only on the last page of a multi page document, and ther may be many documents in a print run.

GuiltyMaggot - The best rock band in the world!
 
DarrenWard

This there any other way of getting the total at the bottom of the page only on the last page

Its pretty unconventional. I would have used a more known method of printing the report twice (the first time getting the last page number) and using PrintWhen to make the total appear on the last page number.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Is not a report.

Is a document print run, ie. print all of todays invoices.
Individual invoices could be either one page or multiple pages, but only want totals on last page of document. GuiltyMaggot - The best rock band in the world!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top