TfrxUserDataSet and GetValue Problem
Kutscher
Sauerland, Germany
Hello,
we have a little problem here with TfrxUserDataSet and the TfrxReport GetValue Method. We use the C++ Builder 5 and Turbo C++.
With both IDEs we have the same problem:
We designed a Report that needs two Values, that are
Username and Usernumber. The Username is "connected" with a TfrxMemoView
while the Usernumber is connected with a TfrxBarView.
The problem we have is that the Usernumber works, the Username is not working.
The GetValue Method from the Report is called, but it always "only" has
the Usernumber in its "Varname" Variable.
Here the sourcecode of the GetValue Method:
void __fastcall TForm1::frxReport1GetValue(const AnsiString VarName,
Variant &Value)
{
if(VarName == "<frxUserDataSet1.\"Username\">")
{
Value = Username->Strings[(frxUserDataSet1->RecNo)];
}
if(VarName == "<frxUserDataSet1.\"Usernumber\">")
{
Value = Usernumber[(frxUserDataSet1->RecNo)];
}
}
Does anybody else have the same problem?
Has someone an idea how we can solve that problem?
Before we bought FastReport we used QuickReport, but we searched for a component that works the same way with C++ Builder 5 and Turbo C++.
We are rookies with FastReport, so if you have an idea, please reply.
Regards
Matthias
we have a little problem here with TfrxUserDataSet and the TfrxReport GetValue Method. We use the C++ Builder 5 and Turbo C++.
With both IDEs we have the same problem:
We designed a Report that needs two Values, that are
Username and Usernumber. The Username is "connected" with a TfrxMemoView
while the Usernumber is connected with a TfrxBarView.
The problem we have is that the Usernumber works, the Username is not working.
The GetValue Method from the Report is called, but it always "only" has
the Usernumber in its "Varname" Variable.
Here the sourcecode of the GetValue Method:
void __fastcall TForm1::frxReport1GetValue(const AnsiString VarName,
Variant &Value)
{
if(VarName == "<frxUserDataSet1.\"Username\">")
{
Value = Username->Strings[(frxUserDataSet1->RecNo)];
}
if(VarName == "<frxUserDataSet1.\"Usernumber\">")
{
Value = Usernumber[(frxUserDataSet1->RecNo)];
}
}
Does anybody else have the same problem?
Has someone an idea how we can solve that problem?
Before we bought FastReport we used QuickReport, but we searched for a component that works the same way with C++ Builder 5 and Turbo C++.
We are rookies with FastReport, so if you have an idea, please reply.
Regards
Matthias
Comments
Type the following text in this object:
[My Variable]
Now create the TfrxReport.OnGetValue event handler:
procedure TForm1.frxReport1GetValue(const VarName: String;
var Value: Variant);
begin
if CompareText(VarName, 'My Variable') = 0 then
Value := 'test'
end;
Run the report and we will see that variable is shown correctly. The TfrxReport.OnGetValue event handler is called each time when FastReport finds unknown variable. The event handler should return a value of that variable.
sorry but you will have to translate to c
"The TfrxReport.OnGetValue event handler is called each time when FastReport finds unknown variable. The event handler should return a value of that variable."
Thanks for the explanation, but the "Username" and "Usernumber" were put in the same way into the report and the event handler only asked for the "Usernumber" never the "Username". The Reports always showed a '0' instead of the "Username".
Is there a limitation of how many "Fields" a TfrxUserDataSet can have?
Anyway with your hint we can now make our reports.
Here the C++ Code if someone needs:
void __fastcall TForm1::frxReport1GetValue(const AnsiString VarName,
Variant &Value)
{
if(VarName == "My Variable")
{
Value = "test";
}
}
think of a userdataset as only positioning the databand to the correct record(row) according to the props and event handlers you have written for the tfrxuserdataset.
or for controlling the nuber of times a report is run if connected to the tfrxreport component itself in multi designpage reports.
the memo of the text objects(fields within the databand) receive their values through the onget value event, as they are unknown