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

Where do functions go in Reports ?

Status
Not open for further replies.

xBaseDude

MIS
Jan 31, 2002
357
0
0
US
VFP7.0 SP1

Where can I put a function for formating a field in a report using the report writer?

I want to use this function...

SET CENTURY OFF

CLEAR
? Longdate({^1998-02-16}) && Displays Monday, February 16, 98

SET CENTURY ON
? Longdate({^1998-02-16}) && Displays Monday, February 16, 1998

*** LongDate ***

FUNCTION longdate
PARAMETERS gdDate
RETURN CDOW(gdDate) + ', ' + MDY(gdDate)

TIA - Wayne

 
xBaseDude

If you want to format a field in your report, create your function in your main program, and in the text box of the field or your report use :
longdate()



Mike Gagnon

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

Thanx for taking the time to respond...

create your function in your main program

Could I ask you to be more specific. I tried adding it as a method to the current form that calls the report, and no joy.

TIA - Wayne

 
if you want to use a method in a form, may I suggest then you create a public instance of the form so you can then refer to it in your report. To instanciate your form use:
Code:
Public oForm
DO FORM myForm.scx NAME oForm

And in your report's textbox use:
oForm.LongDate()






Mike Gagnon

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

The way I have always done this is to have a special file, called ReportProcs (or something similar). This contains all the functions that you want to call from reports. Then, when you start up your application, include this code:

SET PROCEDURE TO ReportProcs ADDITIVE

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
To expand on Mike's "create your function in your main program"...

You want to put your FUNCTION longdate somewhere such that it can be "seen" by the Report Form during its execution.

To do that you could:
1. Put FUNCTION longdate in your PROCEDURE file
2. If you are calling your Report from a PRG file, you could but your the FUNCTION longdate within the PRG file.
3. If you were calling your Report from a FORM, you could make your FUNCTION longdate a custom Method of the Form and call it with a
MyForm.Longdate(ThisDate)

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top