Get value of TFrxMemoView on prepared report

Hi,

I need to get the value of a TFrxMemoView after the report has been prepared:

I use this code to find the object:
frxReport1.PrepareReport
  tmpObj := frxReport.FindObject('MemoTelNumber');

but when i use this to get the value from the MemoView:
  tmpValue :=   TfrxMemoView(tmpObj).Text;
it returns the fieldname: [MyDataSet.TelNumber]

the only workaround is to use this code:
  tmpValue := TfrxMemoView(tmpObj).DataSet.Value[ TfrxMemoView(tmpObj).DataField ]
but this will only work if the memoview contains a field (not a function, or just plain text)

So, does anyone know how to get the value that is displayed/printed from a memoview?

Thanks for the help!

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 4:16AM
    see the interactive report in the main demo.
    also note that what you are retreiving is the design contents of the memo
    you could have many occurences of a memoview depending upon band record counts.
  • edited 4:16AM
    Hi Gordk,

    I reviewed the interactive demo, but it only shows a handler for the onclick-event.
    In this case, the report is not shown to the user. It runs in the background, without a preview.
    gordk wrote: »
    also note that what you are retreiving is the design contents of the memo
    you could have many occurences of a memoview depending upon band record counts.
    Exactly. I want to get access to the runtime contents of the memoview. Do you know how to get that?

    I understand, depending of the band the controls are placed on, i could have many occurences of the same memoview,
    but i only need one of them. Since these controls are for my internal use only, i intend to put them on the datapage (if this is possible ?), or otherwise put them in the reporttitle band.

    Thanks
  • gordkgordk St.Catherines On. Canada.
    edited 4:16AM
    you could try using the oap event of the report component to read the tagstring.
    inside the report in the oad event of the memoview put the text in the tagstring
  • edited 4:16AM
    gordk wrote: »
    you could try using the oap event of the report component to read the tagstring.
    inside the report in the oad event of the memoview put the text in the tagstring

    Gordk,

    I'll explain my intention:

    I have a custom report DLL which works with standalone reportfiles. All datasets are defined inside the report.
    The user can use this DLL to print reports (of course:-) and to send reports by email.

    For example: an order confirmation is sent to the customer's emailaddress.
    Since the datasets are defined inside the report, i don't know the customers emailaddress untill the user actually runs the report, at that point, the data is pulled from the database and the report is build.

    To get the emailaddress and other data, the reportfiles have hidden MemoView objects with a predefined name (EMAIL_RecipientAddress, EMAIL_ContactName, etc).

    When the user clicks the "Send mail" button, the report is prepared, i look for the hidden MemoView objects (which should hold the actual data now because the report has been parsed), and get the emailaddress from there.

    The value of these hidden memoviews can be set by the user by changing the report's design and filling in a value in the MemoView objects. This can be a fieldname (for example [Customer."Email"]) or a static text (For example "accountant@mycompany.com" in case the report always needs to be sent to the same address) or even a function (Example : [IIF(Customer."PrimaryEmail" <> '', Customer."PrimaryEmail", Customer."SecondEmail")] )



  • gordkgordk St.Catherines On. Canada.
    edited 4:16AM
    my prefrence would be to use a set of categorized variables and store the inputed values in the variables
    which then can be used for display within a memoview and their values, and can be acessed from any event of the tfrxreport component.
  • edited 4:16AM
    gordk wrote: »
    my prefrence would be to use a set of categorized variables and store the inputed values in the variables
    which then can be used for display within a memoview and their values, and can be acessed from any event of the tfrxreport component.

    Gordk,

    I agree that this would be the best practice.
    However, we have 100's of customers, who each have a few dozen reports. It's impossible for us to explain to each one of them how to define variables and maybe even add code to their reports. Adding a memo-object with a predefined name is about as far as we can go...

    Also, sometimes a report needs to be sent to more than one address. It's easy for the designer to add a memo-object to a detailband.
    I can collect all the different addresses from the report and take care of the actual sending in my code.

    If you have an answer on how to collect the values, that would mean a lot for me. (a code sample would be an incredible help!)

    Thank you, Jan

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.