Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 546
  • Last Modified:

Crystal Reports: database table lookup in formula

I'm using Crystal Reports for VS 2010. In a CR formula I'd like to be able to lookup a database table. The function would be something like this:
   lookup(tablename, pk_col, result_col).

For example, lookup("States", "StateCode", "StateName") would look up a state code such as "AK" from table "States" and return "Alaska".

Is there any such thing?
0
BlearyEye
Asked:
BlearyEye
1 Solution
 
mlmccCommented:
The full versions of Crystal have what os called a SQL Expression.

Check the field explorer to see if you have that.
If so create a new one.  It is just basically SQL but it can only return a single VALUE.

Something like

SELECT FullStatename FROM States WHERE StateCode = {StateCodeField}


mlmcc
0
 
GJParkerCommented:
This isn't practical in CR without using subreports which would have an impact on performance. Why can't you simply add the states table to the report and link on the statecode field.
0
 
BlearyEyeAuthor Commented:
The SELECT expression doesn't seem to work in the VS version. That's too bad, since it would be nice if it were available. But adding the extra tables did the trick.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now