Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: a variable cannot be redeclared with a different Post Reply Post New Topic
Author Message
coolfire
Newbie
Newbie


Joined: 04 Aug 2015
Location: Canada
Online Status: Offline
Posts: 5
Quote coolfire Replybullet Topic: a variable cannot be redeclared with a different
    Posted: 14 Dec 2015 at 5:23am
I am trying to pass a field from sub report

When I use this, it return 0.00
WhilePrintingRecords;
SHARED numbervar A := tonumber({PMCONO.VALUE});

When I use this, it gave me an error
"a variable cannot be redeclared with a different type"
WhilePrintingRecords;
Shared stringVar A:={PMCONO.VALUE};

It is an optional field from ERP and it is supposed to be a date. I will need to use this date to calculate summary

Thanks
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 14 Dec 2015 at 11:46am
When you use a shared or global variable, it must be declared as the same data type in all places. 

I do not understand why you have declared as a number in one place and a string in another place, but you say it is a date.  FYI: For most databases, a date is really a number internally.
IP IP Logged
coolfire
Newbie
Newbie


Joined: 04 Aug 2015
Location: Canada
Online Status: Offline
Posts: 5
Quote coolfire Replybullet Posted: 15 Dec 2015 at 2:18am
I am trying to pass it from sub to main report but no success.

numbervar returns 0.00 which should be 12/01/2016
StringVar and DateVar returns "a variable cannot be redeclared with a different type"

How am I able to pass it to main report?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 15 Dec 2015 at 7:05am
First off, so that you can get the value to show in the sub-report.  Either remove the shared variable from the main report or created  a new shared variable (for  testing purposes) that is a datevar datatype and see if you can assign the database field to that variable.  If that works, then change the datatype of the variable to the datevar.  Otherwise, keep trying other datatypes until you can get it work (I do not know why it would not work as datevar, but then I do not now your database).
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.029 seconds.