×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to save the value of column from the first record to a global variable and use it later?

how to save the value of column from the first record to a global variable and use it later?

how to save the value of column from the first record to a global variable and use it later?

(OP)
I need to save a column value from the first row of a command object to a variable so I can use it at the bottom of the report. I sort of new in CR XI and I've spent a lot of time searching, maybe someone here can help me

RE: how to save the value of column from the first record to a global variable and use it later?

How is the column sorted? By date? By item #? Is the column value that you want to grab the sorted value or is it some other field?

Depending upon your answered, the following might work:

Whileprintingrecords;
Numbervar x;
If {table.date}=minimum({table.date}) then
X := {table.quantity};

Then just reference in the report footer:

Whileprintingrecords;
Numbervar x;

You could alternatively set up a variable to count the records, like this:

Whileprintingrecords;
Numbervar cnt := cnt + 1;
Numbervar x;
If cnt=1 then
X := {table.quantity;

-LB

RE: how to save the value of column from the first record to a global variable and use it later?

(OP)
the case is that I get a resultset from a command object returning 11 rows looking like this:
customer-code,address, qty,amount.
it happens that sometimes the last rows can be returned with Nulls, but I need to print the address in the footer. since all the rows qould be for the same customer-code and address, I need to save the first or lastnon-null address to a variable and print it in the footer.
in your example where do i put those formulas? do I create a formula field?
hope you can help me further
MP

RE: how to save the value of column from the first record to a global variable and use it later?

Questions:

Do you have any groups?

What if there are more than one customer on the page? What would you want to happen?

What footer section are you referring to? A group footer? A page footer? Report footer?

-LB

RE: how to save the value of column from the first record to a global variable and use it later?

(OP)
thanks for your response LB
-No Groups, this is like an invoice
so in the the detail section, it prints the items sold for a customer's invoice
I referring to a Page Footer (the II have to print the address , but since the last row is nulls I need to save the last value (or the firs as they wiil be for the same customer address)

MP

RE: how to save the value of column from the first record to a global variable and use it later?

Put this formula in the detail section and suppress it:

Whileprintingrecords;
Stringvar x := “”; //replace these iPad quotes with your own, please!
If not isnull({command.address}} and
Trim({command.address}) <> “” then //replace these quotes
x := {command.address};

Put this formula in the page footer:

Whileprintingrecords;
Stringvar x;

-LB

RE: how to save the value of column from the first record to a global variable and use it later?

(OP)
when putting the formula in the Detail section I get error "the formula result must be a boolean"
MP

RE: how to save the value of column from the first record to a global variable and use it later?

(OP)
this is my version of what you suggested me to put in detail, what am I missing?

Whileprintingrecords;
Stringvar usps:= "";
If not isnull({Command.MailAddr}) and
Trim({command.MailAddr}) <> "" then
usps:={command.MailAddr};

RE: how to save the value of column from the first record to a global variable and use it later?

You should be creating this formula in the field explorer->formula editor->new (pencil icon, I think). I think you must have entered it as a selection formula.

-LB

RE: how to save the value of column from the first record to a global variable and use it later?

(OP)
you said to put the formula in the Detail Section and suppress it Do you mean I have to create a formula field?
pleae advise
MP

RE: how to save the value of column from the first record to a global variable and use it later?

Yes, create the formula and then place it in the detail section. Then right click on it->format field->suppress. THis is just so the address doesn’t appear again in the detail section. This formula is just going to carry the value and make it available in the page footer.

-LB

RE: how to save the value of column from the first record to a global variable and use it later?

(OP)
okay thanks for clarifying!. so I've create a formula field called SaveAdr with the above formula on it, added it to the detail and suppressed it . no errors so far. now how do I used the variable in the footer? I don't understand your suggestion from above :
----------------------
Put this formula in the page footer:
Whileprintingrecords;
Stringvar x;




- do you mean to create another formula field with that formula and insert it into the footer?

let me know
thanks!
MP

RE: how to save the value of column from the first record to a global variable and use it later?

Yes.

-LB

RE: how to save the value of column from the first record to a global variable and use it later?

(OP)
Thank LB, very helpful your suggestions, but now I face a change in the scope of the report, what happens is that this will print in a pre-printed form that allows only 11 lines withe detail, but there is a 12th line in the form where I'm suppossed to print a parameter entered. i t seems simple si I put the parameter printing in the repport footer, but it turns out that the command object can return less than 11 lines for the detail so I need to create a logic where the report inserts blank lines when the lines to reach 11,any advise on how to do that? sorry to be a pain!
MP

RE: how to save the value of column from the first record to a global variable and use it later?

Go into the section expert->report footer and check “print at bottom of page”.

-LB

RE: how to save the value of column from the first record to a global variable and use it later?

(OP)
but the parameter value has to always print in the 12th line, wouldn't bottom of the page make it print at the bottom part of the page?(too far from line 12th which is around the half of the page) or bottom of the page is like "bottom of the section?)
thanks in advance
MP

RE: how to save the value of column from the first record to a global variable and use it later?

Is this report always just one page long? What is the parameter type and how is it used? Does it select a customer code for example? It might not be relevant to the solution, but please answer.

-LB

RE: how to save the value of column from the first record to a global variable and use it later?

If the report is always for one customer, for example (use whatever field that has the same value for all details), then insert a group on {table.customer} and place the parameter in the group footer. YOu can suppress the group header, if you like.

Sorry for misunderstanding earlier.

-LB

RE: how to save the value of column from the first record to a global variable and use it later?

(OP)
great help, I'm getting closer to have it working!
thx
MP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close