Hi
I have below code in Sub Report -
DECLARE @TipoObjeto VARCHAR(10)
DECLARE @DocEntry INT
DECLARE @Comando VARCHAR(MAX)
DECLARE @Tabela VARCHAR(3)
SET @TipoObjeto = x
In Main Report i have given
Shared NumberVar x := 5;
Hi
I have below code in Sub Report -
DECLARE @TipoObjeto VARCHAR(10)
DECLARE @DocEntry INT
DECLARE @Comando VARCHAR(MAX)
DECLARE @Tabela VARCHAR(3)
SET @TipoObjeto = x
In Main Report i have given
Shared NumberVar x := 5;
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Aug 20, 2023, 1:40 PM EDT
In Crystal Reports, shared variables need to be declared at the beginning of the formula and before they are used. Here's some modification:
Main Report:
Shared NumberVar x := 5;
Sub Report:
// Declare the shared variable at the beginning of the formula
Shared NumberVar x;
// Your Variables in sub report
DECLARE @TipoObjeto VARCHAR(10);
DECLARE @DocEntry INT;
DECLARE @Comando VARCHAR(MAX);
DECLARE @Tabela VARCHAR(3);
// Assign the shared variable value to a local variable
x := {@MainReportFormula}; // This retrieves the value of x from the main report
// Now you can use x in your subreport code
SET @TipoObjeto = ToText(x);
Soumyakanta RoutRank #4,912 · 319 reputationPosted Aug 21, 2023, 12:45 AM EDT
DECLARE @TipoObjeto VARCHAR(10)
DECLARE @DocEntry INT
DECLARE @Comando VARCHAR(MAX)
DECLARE @Tabela VARCHAR(3)
SET @TipoObjeto = SharedNumberVar x -- Use SharedNumberVar to access the shared variable value