- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Working with Parameters as Arrays
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-14-2010 09:57 AM
I have a parameter that allows the user to select the months they wish the report of include. They can select any calendar month(s) from 1 to 12. The parameter is numeric. The parameter is called SalesMonths. I have created a Formula called DispMonth. The code for this formula is as follows:
Global SalesMonths(12) as number
Global DispMonth as string
Dim i as number
DispMonth=""
for i=salesmonths(1) to salesmonths(12) step 1
if i >0 then
DispMonth=DispMonth & ", " & monthname(i)
end if
next i
formula=DispMonth
I wish to display in the page header DispMonth which would be a string expression of the months selected for the report.
Somewhere I seem to be missing an important concept as I can't seem to get anything to display. Appreciate assistance in solving what I'm doing incorrectly.
Thanks
Fred
Re: Working with Parameters as Arrays
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-14-2010 10:23 AM
Why not just use a string parameter and the Join function would be available.
formula = Join({?SalesMonths},",")Your record selection logic for whether a record would be included would become:
ToText(Month({AR_InvoiceHistoryHeader.InvoiceDate} ),"0") in Join({?Multiples},",")
Re: Working with Parameters as Arrays
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-14-2010 10:52 AM
connex wrote:Why not just use a string parameter and the Join function would be available.
formula = Join({?SalesMonths},",")Your record selection logic for whether a record would be included would become:
ToText(Month({AR_InvoiceHistoryHeader.InvoiceDate}),"0") in Join({?Multiples},",")
When the user selects the months they want to be included in the report the parameter asks for a month number, i.e. 1 is january, 7 is july etc. What I want to display in the page header is the monthname for each of their selections. Where the user is making multiple selections for the parameter does not the force the parameter to be an array? The parameter is numeric which will be used in record selection withing the detail of the report. I'm new to Crystal Dan so not sure about the "join" and "?Multiples.
Fred
Re: Working with Parameters as Arrays
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-14-2010 11:06 AM
Fred,
What I am telling you is that life is much easier if you change your report to use a string type array parameter instead of numberic one. I probably confused you because in my example "?Multiples" should have been "?SalesMonths" (same parameter as in the 1st snippet) in the second code snippet.
Yes, you should use arrays and that's what I'm doing in the example. The Join function takes a set of values and strings them together with the second argument (comma in this case).
It's just easier to deal with string type parameters and if you need to compare them to numbers - convert what ever you are comparing them to a string as I show in the second snippet.
Re: Working with Parameters as Arrays
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-14-2010 12:24 PM
connex wrote:Fred,
What I am telling you is that life is much easier if you change your report to use a string type array parameter instead of numberic one. I probably confused you because in my example "?Multiples" should have been "?SalesMonths" (same parameter as in the 1st snippet) in the second code snippet.
Yes, you should use arrays and that's what I'm doing in the example. The Join function takes a set of values and strings them together with the second argument (comma in this case).
It's just easier to deal with string type parameters and if you need to compare them to numbers - convert what ever you are comparing them to a string as I show in the second snippet.
Dan:
The Join works fine when I make the parameter a string. Is there a function that converts "January" to 1, February to 2 etc.?
It might be academic but why does not my code snipit I originally attempted to use not work?
Re: Working with Parameters as Arrays
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-14-2010 01:15 PM
Usually people convert 1 to "January" and not the other way around with this Crystal language technique:
MonthName (Month({AR_InvoiceHistoryHeader.InvoiceDate}))
Regarding your failing code: I don't do much Basic syntax off the cuff. Maybe someone else will chime in. I figure why learn two syntaxes due to the REQUIREMENT that all selection criteria must use Crystal syntax. I usually just stick with the one - Crystal.


