Normal Topic Variable in Report Header (Read 1362 times)
NICEBERG
Full Member
Members
***
Offline


I came, I saw, I'm still
trying to figure it out!

Posts: 208
Location: Green Bay, WI
Joined: Dec 17th, 2003
Variable in Report Header
Aug 13th, 2006 at 11:05am
Print Post Print Post  
Is there a way to include a variable in a report header?

I have a combo box with predetermined numbers (30-60-90-180-365) that a user selects to determine how many months worth of data to retrieve. I can capture the info: var vReportdays as Int. I would like my header to read: This report is for the past number of days: (number). I've added the static text okay, but can't figure out how to insert the variable.

Thanks for any help!
Clueless in Green Bay,
Fred
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Variable in Report Header
Reply #1 - Aug 13th, 2006 at 8:29pm
Print Post Print Post  
Hi Fred


A variable is not actually needed.  You can use the value of the Combo Box element.

Add a Value Box to the Report Header, name it "Header"

Go to the Program Editor in the Report Designer.
Go the element for Header and enter the following code:
Code
Select All
Header = "The report is for the past number of days: " + ComboElementName 



If you want to use a variable instead of the value of the combo box element then do this:
Code
Select All
var vReportdays as String
vReportDays = ComboElementName
Header = "The report os for the past number of days: " + vReportdays 



Or if you already have vReportDays as an Int then:
Code
Select All
Header = "The report is for the past number of days: " + @Str(vReportdays) 

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
NICEBERG
Full Member
Members
***
Offline


I came, I saw, I'm still
trying to figure it out!

Posts: 208
Location: Green Bay, WI
Joined: Dec 17th, 2003
Re: Variable in Report Header
Reply #2 - Aug 13th, 2006 at 10:34pm
Print Post Print Post  
Hi Bob,
 I can't use the value of the combo box because there is no value in the combo box once the records are retrieved. I use the combo box to provide information to a variable which does a calculation on the date field to establish a range of records to retrieve. The retrieve criteria are cleared and then the records are returned.

 I've saved the contents of the combo box to a variable, but apparently this information is not available to the "on print" programming. I tried it as per your third example: "Or if you already have VReportDays as an Int then:" When I enter my variable, VDaynumb as Int, and then VDaynumb = Entered (my date LE) in the programming for the command button I would have assumed the variable would be available for the print spec. I guess I'm missing something.

 My code in "on print" is: Header = "The report...of days: " + @Str(vDaynumb). When I do the "test" - the carat points to the "v" in vDaynumb.

 BTW - I didn't think ANYBODY else besides me was at the site today -- "HI"  LOL

Thanks,
Fred
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Variable in Report Header
Reply #3 - Aug 13th, 2006 at 10:38pm
Print Post Print Post  
Fred,

Put the value in a GlobalValue. Then you can get it when the report runs using @GlobalValue.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Variable in Report Header
Reply #4 - Aug 13th, 2006 at 11:34pm
Print Post Print Post  
Erika was  back sooner than I was.  When I read your response, I was also going to suggest GlobalValue.

1.  When you said you are saving the value as a variable, I am curious about how/when you are doing that?
------------------------
Quote:
When I do the "test" - the carat points to the "v" in vDaynumb.
2.  That is probably because vDayNumb has not been declared earlier as a variable.
-----------------------
3.  The GlobalValue can be set in almost any programming field on any form/report.

The GlobalValue can be set like this:
GlobalValue("vReportdays",ComboElementValue)  or like this:
GlobalValue("vReportdays","60") or similar method.

And then in the report do this:
Header = "The report...of days: " + @GlobalValue("vReportdays")
-------------------------------
« Last Edit: Aug 14th, 2006 at 3:21pm by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
NICEBERG
Full Member
Members
***
Offline


I came, I saw, I'm still
trying to figure it out!

Posts: 208
Location: Green Bay, WI
Joined: Dec 17th, 2003
Re: Variable in Report Header
Reply #5 - Aug 14th, 2006 at 2:20pm
Print Post Print Post  
Good morning to all.

Okay, I understand conceptually what's supposed to happen. I'm having difficulties with the application however.

Scenario:
Combobox named: Days_To_Retrieve  (choices 30-60-90,etc)
Programming: Days_To_Retrieve (on element exit)
   Globalvalue("vDays",Days_To_Retrieve)
   WriteLn(@GlobalValue("vDays")   --returns nothing

Report:
  Value box named: Header
  Header = "Number of days retrieved:" + @GlobalValue("vDays")

I assume since I'm not getting any information from the WriteLn command that I'm missing something simple (or not).

Thanks for your patience!
Fred
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Variable in Report Header
Reply #6 - Aug 14th, 2006 at 3:14pm
Print Post Print Post  
You would not want the programming to be in the On Element Exit event of the Combo box. The On Element Exit events do not run on the Retrieve spec which is where the data is at.

In an earlier post you said...
Quote:
I can't use the value of the combo box because there is no value in the combo box once the records are retrieved. I use the combo box to provide information to a variable which does a calculation on the date field to establish a range of records to retrieve. The retrieve criteria are cleared and then the records are returned.


You will want to store the date range in the Global Value in the same event that you are doing the calculations to establish a range of records to retrieve.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NICEBERG
Full Member
Members
***
Offline


I came, I saw, I'm still
trying to figure it out!

Posts: 208
Location: Green Bay, WI
Joined: Dec 17th, 2003
Re: Variable in Report Header
Reply #7 - Aug 14th, 2006 at 3:30pm
Print Post Print Post  
Thanks Ray! -works like a charm.
  
Back to top
 
IP Logged