Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Check for field availability in formula Post Reply Post New Topic
Author Message
vaishali
Newbie
Newbie


Joined: 07 May 2008
Online Status: Offline
Posts: 4
Quote vaishali Replybullet Topic: Check for field availability in formula
    Posted: 07 May 2008 at 6:36am
I am new to crystal report. In my report data are created dynamically. When I print data using formula sometime it gives error because of not availability of perticular field, because filed is created dynamically.
 
So is ther any function available to check the field is exist or not?
 
please spread some light on my problem.
 
thanks in advance
 
Vaishali
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 May 2008 at 10:31am
I'm confused as to how you are creating the field dynamically. Are you using the report creation API to do this, or changing up the SQL query as the datasource? Since you're new to CR, I doubt if you're doing report creation, but maybe so. If so, then you need to modify the formula to account for the fields that are no longer used so that it doesn't try to access non-existent fields.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
vaishali
Newbie
Newbie


Joined: 07 May 2008
Online Status: Offline
Posts: 4
Quote vaishali Replybullet Posted: 07 May 2008 at 11:33am
Thanks for replying.
Actually I didn't wrote report but I am responsible to do some changes and get it work back.
Let me describe my problem in detail again.
 
I am using query as source of report. So the result of query is different(means different number of field). every time.
 
eg. field name like 1st, 2nd, 3rd. sometime the query results like 1st, 2nd.
 
I used 3rd filed in the formula. So when program runs and not find 3rd field, it gives error. So is ther any way to check the field availablility like it exist or not in the code any where.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 May 2008 at 12:33pm

No, you can't do this. However, it would work if you could modify the SQL to return a blank value for Field 3. That way the database structure is consistent across queries and Crystal Reports will get all the fields it expects to see.

Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
vaishali
Newbie
Newbie


Joined: 07 May 2008
Online Status: Offline
Posts: 4
Quote vaishali Replybullet Posted: 07 May 2008 at 12:42pm
Thanks again.
 
my 1st, 2nd and 3rd row generated using pivot. so it totally depends on data so I can't manually add that field. Do you think is ther any other solution for this problem?
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 07 May 2008 at 1:59pm

I may be missing something in the discussion, so my apologies if my answer is off target.

If your query is asking for field1, field2, field3 (and all are valid fields) but your result is returning field1 and field2 then it seems that field3 is null.  You could try changing the setting for exceptions in the formula box. Set it to use default values for nulls. This is done while editing the formula in the upper right corner of the window and changing the option in the drop down box.
 
Failing that you might be able to create default values for variables then change those default values by assigning the data field value.
 
Hope this helps.
 
Regards,
 
John W.
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.016 seconds.