Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Dynamic division forumula Post Reply Post New Topic
<< Prev  Page  of 2
Author Message
rlivermore
Groupie
Groupie


Joined: 27 Sep 2012
Online Status: Offline
Posts: 70
Quote rlivermore Replybullet Posted: 14 Jan 2013 at 11:30am
That helps but when I create a new formula and attempt to save it, it complains.
 
shared numbervar mnths;
local numbervar x :=month({tblServiceOrders.DateReceived});
if x < 12 then
  mnths := x +1;
 
<<< highlights the text below with error: remaining text does not appear to be part of formula >>>
 
else
  mnths := 1;
mnths
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 14 Jan 2013 at 12:10pm
remove the semi colon after x + 1...I never remember if it is necessary or not on the first part of a if then else clause.
 
at least that is the first thing that I would try.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 14 Jan 2013 at 12:12pm
The semi-colon goes at the end of the if statement (unless you have multiple statements embedded in then .. else clauses.

If it gets too complicated, I change over to Basic syntax.  It is a lot easier for me to follow.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 14 Jan 2013 at 12:33pm
yeah, basic is simple that way, but my brain is so used to CR syntax, that even though I program in basic, I find it a pain in CR.
 
I figure adding it can't hurt too much, if I get an error, I remove the semi-colon.
IP IP Logged
rlivermore
Groupie
Groupie


Joined: 27 Sep 2012
Online Status: Offline
Posts: 70
Quote rlivermore Replybullet Posted: 14 Jan 2013 at 1:11pm
Looks like removing the semi colon did the trick. I ran the report for last years data and it seemed to calculate correctly. Thank you for your help!
IP IP Logged
<< Prev  Page  of 2
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