Iterate through data table in Crystal Report
How can i create function to iterate through datatable to read value from table
e.g
Function GetVal(integer id) //iterate here and match value fr开发者_Go百科om table using id return value;
and call this function on report field
i am using crystal report 11
any clues??
Option 1: Make your function (or equivalent SQL query) outside of Crystal and link to it like any other source. The practicality of this option depends on the details of your report.
Option 2: Crystal doesn't have a built-in Get() function that I can find. So, you'll have to get creative with subreports. For example, let say's say you want to get {TargetFld} from {LookupTable} based on {CriteriaFld}:
- Make a subreport. Use {LookupTable} for your data source.
- When entering subreport links, choose {CriteriaFld}.
- In your subreport, make a formula. Use it to create a Shared variable and set the value to whatever value you want to pass back to the main report.
- Position the subreport 1 section above the section where you need to use this value. (Otherwise it won't evaluate when you expect it to).
- Create the Shared variable in the main report.
- Use it as normal.
If you're not familiar with subreports or shared variables, I suggest first looking them up in the Crystal help files (F11). This will make alot more sense that way.
精彩评论