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:
but when i use this to get the value from the MemoView:
the only workaround is to use this code:
So, does anyone know how to get the value that is displayed/printed from a memoview?
Thanks for the help!
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
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.
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.
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
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")] )
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