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

I need assistance with creating an Array. 1

Status
Not open for further replies.

agreen10

IS-IT--Management
Oct 20, 2005
70
US
I am not sure if this is the best way to go about it however, I need to create a report that will look up a check number from 10 different fields and print the field(s) that matches and the amount of the check (this is a seperate field). Eg. there are 10 fields for each month of the year:

janck
febck
marck
aprck etc..

I need to find checknumber(a parameter field) 5007 which might appear in any of all of the fields above.

Do I build an array? what is teh best way to do a lookup of all these fields to get the result?

Thanks in advance for your help. I am new to this function and having great difficult because of the data was setup in the database.
 
You could use a formula like this (this assumes the checknumber is a stringfield):

stringvar array x := [{table.janck},{table.febck},{table.marck}, <etc>];
stringvar array y := ["Jan","Feb","Mar", <etc>];
numbervar i := 0;
stringvar z := "";

for i := 1 to ubound(x) do(
if {?check} = x then
z := y);
z + ": " + (if z <> "" then totext({table.amt}))

-LB
 
Try in the Report->Selectoin Formula->Record:

{table.janck} = {?MyCheckNumber
or
{table.febck} = {?MyCheckNumber
or
{table.marck} = {?MyCheckNumber
<etc.>

This will only return the row(s) that match the check number entered.

If you need further assistance, try posting technical information instead:

Crystal version
Database/connectivity used
Example data
Expected output

Describing requirements without knowing the environment and having samples will net guesswork.

-k
 
thanks synapsevampire, your suggestion worked.
 
The report prints but there is another step. I need it to print only those months that had a payment using the check number. I am using crystal reports 10 in case that information is necessary.

example, I entered a check number 5005 and the report printed

aug
sep
nov
dec
etc

and only september had a check amount
I would only like to print the months that had a check amount.
 
Ahhh, well, you would want to use a suppression for the other fields to verify that they don't match.

Try using a formula in the details instead of the fields containing something like:

if {table.janck} = {?MyCheckNumber then
{table.janck}
else
if {table.febck} = {?MyCheckNumber then
{table.febck}
else
if {table.marck} = {?MyCheckNumber then
{table.marck}
<etc.>

Now just place the formula in the details.

-k
 
Or try my solution, which will identify which field the checknumber is in.

-LB
 
LB: your solution pulls back every row, LBwhich will be MUCH slower.

You could use the array after using the record selection formula I suggested, but you'll likely discover that the array is no faster (probably slower), and simply adds complexity to a fairly simple requirement.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top