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

can a filename of the report be a variable? 2

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
585
PH
Good evening everyone... i have this code that i want to change just a part of it and make it as a variable to make it dynamic...

REPORT FORM TransSCMS2 FOR Details.TransTYPE = tipis AND BETWEEN(ttod((details.deyt)),start,ind) PREVIEW WINDOW (oRepForm.Name) ;
TO PRINTER PROMPT

in the above code, i want the SCMS2 be a variable... would that be possible? if so... would you please teache me how... thanks in advance...
 
Hi,

[pre]lcREPORT='Trans'+'SCMS2'
REPORT FORM (lcREPORT) FOR Details.TransTYPE = tipis AND BETWEEN(ttod((details.deyt)),start,ind) PREVIEW WINDOW (oRepForm.Name) ;
TO PRINTER PROMPT[/pre]



mJindrova
 
I second that approach.

Notice you also always have macro substitution, even for just a partial name, as in

Code:
lcReportType = "SCMS2"
REPORT FORM Trans&lcReportType ...rest from your command

And what also would work is

Code:
lcReportType = "SCMS2"
REPORT FORM ("Trans"+lcReportType) ...rest from your command

And to make good use of this, lcReportType could come from data or some selection a user makes about the report type wanted, it would of course not be hardcoded right before the REPORT command, that would be useless, but it just demoes this works with a variable - wherever that variable gets its value from.

The topics you might want to read up are "name expression" for using brackets enclosing an expression that evaluates to a name, like a table, workarea or file name. Or how & is used which you find under the topic name "macrosubstitution". Especially for file names the name expressions always work. Note one important pitfall: Brackets enclosing an expression might not be used as a name, if put anywhere. One obvious case where a bracket doesn't cause the expression within to be interpreted as a name is, if the expression is not a string that could be the name of something, but also, if a name is not the only thing, that can be expected at place of the name expression. The point is, brackets are not always name expressions, sometimes they are simply brackets.

Chriss
 
Ohhh I see..... sorry for being so dumb.... But so much thanks to you MjinDrova for that fast answer and Chris for always explaining and giving me lots of options.... Thanks again... God bless....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top