TfrxUserDataSet and GetValue Problem

KutscherKutscher Sauerland, Germany
edited February 2008 in FastReport 4.0
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

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 6:56PM
    i am not a c programmer but here is a delphi example
    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
  • KutscherKutscher Sauerland, Germany
    edited 6:56PM
    First I want to thank you for your help.

    "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";
    }
    }
  • gordkgordk St.Catherines On. Canada.
    edited 6:56PM
    IMHO
    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

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.