Link to home
Start Free TrialLog in
Avatar of gibneyt
gibneyt

asked on

Assign SQL field to variable in Crystal Reports

I need to assign a field to a Crystal Reports Variable varSRPAWLaborRate.  The following SQL SELECT statement returns the required correct data:

SELECT        LABRAT_13
FROM            SFC_Work_Center
WHERE        (WRKCTR_13 = 'SRPAW')

I'm using CR 8.5 and need to run calculations using the variable.

What am I missing?  TIA.

Tim
Avatar of Mike McCracken
Mike McCracken

Is that a SQL Expression or the query for the report?

Where is the variable?
DO you have a formula that declares it?
Just assign the value in there

mlmcc
Avatar of gibneyt

ASKER

That is a SQL statement from SSMS.  I tried creating a formula in Formula Editor with the SELECT statement and get an error.  I am missing some little nugget to get this to work.


Tim.
Avatar of gibneyt

ASKER

In CR Formula Editor I have:

numberVar varSRPAWLaborRate:= SELECT {SFC_Work_Center.LABRAT_13}
FROM SFC_Work_Center
WHERE (WRKCTR_13 = 'SRPAW');

An error is thrown on check  and puts the cursor back to the middle line just before SFC_...

<error>
Crystal Reports
!The remaining text does not appear to be part of the formula.
OK
</error>
SOLUTION
Avatar of vasto
vasto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gibneyt

ASKER

mlmcc,

That is it!  Thanks so much.  Now to use the calculated number in the main report.

vasto, you were onto the SQL Expression so partial credit to you but mlmcc provided what would have taken me hours to figure out.  Thanks just the same.

Tim
Avatar of gibneyt

ASKER

mlmcc,

That is it!  Thanks so much.  Now to use the calculated number in the main report.

vasto, you were onto the SQL Expression so partial credit to you but mlmcc provided what would have taken me hours to figure out.  Thanks just the same.

Tim
Tim, It is true that I mentioned SQLExpression, but I cannot consider this answer as helpful.  mlmcc deserves the points.