Print Page | Close Window

a variable cannot be redeclared with a different

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21807
Printed Date: 02 May 2024 at 3:52pm


Topic: a variable cannot be redeclared with a different
Posted By: coolfire
Subject: a variable cannot be redeclared with a different
Date 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



Replies:
Posted By: kevlray
Date 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.


Posted By: coolfire
Date 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?


Posted By: kevlray
Date 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).



Print Page | Close Window