Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Assigning a value Post Reply Post New Topic
Author Message
scotlandc
Newbie
Newbie
Avatar

Joined: 07 Oct 2009
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote scotlandc Replybullet Topic: Assigning a value
    Posted: 07 Oct 2009 at 3:41am
Hello all.
 
Is it possible to check the value of a field then depending on the result, assign the value of that field to another field which will appear in a report?
 
At the top of the report in a header section is a field for customer ID. Depending on the value of that, (if its COM502) assign the value to a field that will appear in the Details section of the report. Obviously, this may mean that it could appear on many lines.
 
In pseudocrystalcode,
 
IF {custID} = "COM502" THEN {ref} = "COM502"
 
Thanks for any help you can provide
 
Scott
IP IP Logged
themessenger
Groupie
Groupie
Avatar

Joined: 15 Aug 2008
Location: United Kingdom
Online Status: Offline
Posts: 48
Quote themessenger Replybullet Posted: 07 Oct 2009 at 3:45am
Yes, something like this in your sql should work:

select case when custid='COM502' then 'COM502' else '' end as ref
from table

Edited by themessenger - 07 Oct 2009 at 3:46am
Managing Director
www.allmymenus.com
IP IP Logged
scotlandc
Newbie
Newbie
Avatar

Joined: 07 Oct 2009
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote scotlandc Replybullet Posted: 07 Oct 2009 at 3:51am
Can you wite SQL in a crystal report formula? I didn't know that. I've been digging around trying to do it in crsytal reports syntax.
 
Thanks :)
IP IP Logged
themessenger
Groupie
Groupie
Avatar

Joined: 15 Aug 2008
Location: United Kingdom
Online Status: Offline
Posts: 48
Quote themessenger Replybullet Posted: 07 Oct 2009 at 4:00am
When you select your tables in the database explorer you can add a 'Command' - you can (if you are on speaking terms with SQL) put pure SQL in there.

You can bypass the entire table construction GUI by putting all of your code in there if needs be. It has come in handy from time to time.

Hope this helps.
Managing Director
www.allmymenus.com
IP IP Logged
scotlandc
Newbie
Newbie
Avatar

Joined: 07 Oct 2009
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote scotlandc Replybullet Posted: 07 Oct 2009 at 4:03am
Yeah, me and SQL are old drinking buddies. Well, I used it and it made me want to drink a lot.
 
Didn't know that about the Command. Useful tip, thank you.
 
 
Edit: The owner of the reports is being precious about it and wants it done in Crystal syntax as everything else is done that way.
 
Can anyone help with this?
 
Thanks

S


Edited by scotlandc - 07 Oct 2009 at 6:13am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Oct 2009 at 7:18am
You cannot alter an existing field but you can create a new field as a formula field and use it in the report although I am not sure this will resolve your problem. Can you explain further what you are trying to accomplish via this process.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.015 seconds.