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

Can I assign a value to a variable using the variable as the first value?

Status
Not open for further replies.

PhilB2

Programmer
Nov 6, 2003
133
US
I'm attempting to create a global string variable in a formula that I place in a group section, assigning it a meaningless value such as space, and then in the detail section, assign it a value of itself followed by an itemID, then comma. The idea is to create a comma-delimited string of values to which I can compare separate itemID's in the detail section of a subreport. (If I need to use an array instead, I'll tackle that. In the meantime, I haven't succeeded in assigning a value in the detail section.)

I was able to declare the variable:

Global StringVar IDlist := ","

but I can't get the correct syntax, or there is some other problem, when I try to assign any value to the variable in a separate formula just for that purpose in the detail section:

IDlist := "hello"

When I try to save the formula, the whole formula becomes highlighted and the error message is "The remaining text does not appear to be part of the formula."

The ultimate goal is to concatenate values each time a detail record is processed, like this:

IDlist = ID_list + {@ITEM_ID} + ","


 
(Sorry, I left out the colon :)=) in the last item.)
 
Someone at work found examples in the Crystal Reports 9 Help function that I somehow had missed. The examples showed that the variable must be declared again, like this:

StringVar IDlist := IDlist + {@ITEM_ID} + ","

I don't know whether the 'Shared' or 'Global', if they are used, needs to be included in the detail section formula. Also, I had an error in the first post: 'ID_list' should have been 'IDlist'.
 
This thread may be closed, since I provided the solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top