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

Convert String To Formula Reference

Status
Not open for further replies.

SJMcAbney

Programmer
Jan 16, 2005
112
GB
I'm wanting to create a loop in crystal that moves through 12 formulas, numbered 1 to 12. Is there any way that I can create a string in the loop and have it reference as a formula?

This is what I have:


numberVar Total := 0;
numberVar Counter := 0;

For Counter := 1 To 12 Step 1 Do (
If Not IsNull({#Month1}) Then
Total = Total + {Month1}
);




I'd be looking to do something like this:



numberVar Total := 0;
numberVar Counter := 0;

For Counter := 1 To 12 Step 1 Do (
If Not IsNull("Month" & Counter) Then
Total = Total + ("Month" & Counter)
);

I just don't know of any keyword that would convert text to a formula reference.


Stewart J. McAbney | Talk History
 
I think you would be better off explaining what you want your report to do rather than assuming that this looping formula is the optimal solution.

-LB
 
Sorry, there's already a solution in place but I know the loop is the optimal solution.

If I can't convert something to a field (i.e. VBA .Fields("Text" & i) then that's fine, I'll just put the formulae into an array and use the counter to reference the elements.

I was just wondering if it was possible to convert, in any way, where x = 5, "Month" & x into {Month5}

Stewart J. McAbney | Talk History
 
Switch (

month="Jan", 01,
month="Feb", 02,
etc,,,

)

basically store the month as a number - When needed convert from number to words
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top