KB-36292: Changing a Report’s figure at run time.

Question:

Can I change a Report’s figure at run time before printing it?

Solution:

Yes, you can. To do so, follow these procedures:

1. Add a Historic with a field linked to an Internal Tag responsible for receiving the image’s path, and set it to not record registers anymore (recording time = 0);
2. On the Report, add a Figure object and a Data Field;
3. On the Report’s Query, write the following script:

SELECT TemperatureTable.E3TimeStamp,TemperatureTable.Temperature1,TemperatureTable.Temperature2 ,(select (LocalImage) from TabLocalImage) as Image
FROM TemperatureTable
WHERE ( TemperatureTable.E3TimeStamp  > #<%InitialDate%>#  AND   TemperatureTable.E3TimeStamp < #<%FinalDate%># )
ORDER BY TemperatureTable.E3TimeStamp  ASC

4. On the Data Field’s DataField property, set the Image’s Visible property as False (variable created on the Query’s SQL tab);
5. On the Report, you must write the following script to pass the image’s path to the Report’s Figure object:

Sub OnFormatSet FigureName = Report.Sections(“PageHeader”).Controls(“Field1”)
Set Image = Report.Sections(“PageHeader”).Controls(“Image1”)
Image.Picture = LoadPicture(FigureName)End Sub

6. Before printing the Report, you must pass the image’s path to the Historic’s register created on the first step:

  • Create a Query in the same screen where the button that performs the printing is;
  • Add a table with only a register of the image’s path;
  • Add this register to the Query;
  • On the SQL tab, enable the option to edit the SQL’s structure and write the following command:

UPDATE TabLocalImage
SET LocalImage = ‘<%ImagePath%>‘

  • On the script that prints the Report, add the following script lines to retrieve the image and update the image’s path on the Historic:
‘Loads the selected image into a tag to be saved on the Historic
Application.ShowFilePicker True, ImagePath
Application.GetObject(“Data.ImagePath”).Value = ImagePath‘Records the image’s path on the Historic
Screen.Item(“ImageQuery”).SetVariableValue “ImagePath”, ImagePath
Screen.Item(“ImageQuery”).Execute(True)

For more details, check the attached example application.

 

Attachments:

ExReportPhoto.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *