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

Need help with simple formula

Status
Not open for further replies.

icarus5000

Technical User
May 15, 2003
16
0
0
US
I'm a VB programmer just starting to get to grips with crystal formulas. I created a formula field @myField and I need to assign it's value based on another fields value.
I tried a simple select case but I keep getting the error "Statement expected here"

Select Case {vw_compfieldmap.groupchoice}
Case "dpt"
{vw_compfieldmap.dpt}
Case "jobcode"
{vw_compfieldmap.jobcode}
Case "jobloc"
{vw_compfieldmap.jobloc}
Case "jobdesc"
{vw_compfieldmap.jobdesc}
End Select

Thanks in advance,
-Ic
 
Are you attempting to use Basic or Crystal Syntax within your formulas?
 
Was trying to use Basic but I don't have a preference. Easier is better in my book.
 
found a solution. I'm slowly getting the hang of the way crystal parses expressions.

if ({vw_compfieldmap.groupchoice}="dpt") then
formula = ToText({vw_compfieldmap.dpt})
End if

if ({vw_compfieldmap.groupchoice}="jobcode") then
formula = ToText({vw_compfieldmap.jobcode})
End if

if ({vw_compfieldmap.groupchoice}="jobloc") then
formula = ToText({vw_compfieldmap.jobloc})
End if

if ({vw_compfieldmap.groupchoice}="jobdesc") then
formula = ToText({vw_compfieldmap.jobdesc})
End if
 
To use the select case approach, you would use the following syntax in Crystal:

Select {vw_compfieldmap.groupchoice}
Case "dpt" : totext({vw_compfieldmap.dpt})
Case "jobcode" : totext({vw_compfieldmap.jobcode})
Case "jobloc" : totext({vw_compfieldmap.jobloc})
Case "jobdesc" : totext({vw_compfieldmap.jobdesc})
Default : "";

(Although it looks like some of the fields might already be text and not require conversion with "totext"--even though your example does suggest that they all require conversion.)

-LB

 
Thanks.
This is the select statement I was trying to come up with. More efficent than evaluating four IF statements.

-Ic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top