Problem loading a report

Discuss the database features

Problem loading a report

Postby arfgh » Wed Aug 30, 2017 1:53 pm

I just used the little code ahead to reload the current report document:

dim rp as object
rp = ThisDatabaseDocument.ReportDocuments.getByName(getDocTitle)
rp.close()
rp.open()


... and works fine, but not if we place the report into a folder. In fact i dont know how to load a report from basic, when it is located into a folder.
Help.

thx in advance
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm

Re: Problem loading a report

Postby Villeroy » Wed Aug 30, 2017 2:58 pm

Use MRI :!:
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24584
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Problem loading a report

Postby UnklDonald418 » Wed Aug 30, 2017 8:29 pm

i dont know how to load a report from basic, when it is located into a folder.

As Villeroy suggested, if you use the MRI tool you should be able to see that accessing a report in a folder works just like accessing a subForm from a Form.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.4 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 574
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Problem loading a report

Postby arfgh » Wed Aug 30, 2017 11:15 pm

ok, but some tip will be welcome.
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm

Re: Problem loading a report

Postby UnklDonald418 » Thu Aug 31, 2017 5:05 pm

Since you didn't seem to understand the hint I gave how about a lesson in using the MRI tool.
Assuming you have installed and enabled the MRI extension.
Near the beginning of your macro insert the following code to make sure the MRI tool is available inside your macro (the MRI library is loaded and the UNO service is started)
Code: Select all   Expand viewCollapse view
If Not Globalscope.BasicLibraries.isLibraryLoaded("MRILib") Then
      Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
End If
oMRI = CreateUnoService( "mytools.Mri" )

Using ThisDatabaseDocument directly in macro statements can be risky. While it isn't likely to be an issue in your little macro you should get in the habit of assigning it with something like
Code: Select all   Expand viewCollapse view
oDoc = ThisDatabaseDocument

using oDoc throughout the remainder of the macro is safer. Your assignment of “rp” becomes
Code: Select all   Expand viewCollapse view
rp = oDoc.ReportDocuments.getByName(getDocTitle)

Insert the following statement after you have assigned “oDoc” and before you assign “rp”
Code: Select all   Expand viewCollapse view
oMRI.inspect oDoc

Open the IDE (<Alt> F11). Locate your macro and select Edit. Set a breakpoint on the line “rp = oDoc.ReportDocuments.getByName(getDocTitle)” and then click on the Run icon.
Execution should stop at the line with the breakpoint and you should also now see a MRI dialog.
By default the MRI dialog opens with the Properties tab selected.
Scroll through the list of properties and select “ReportDocuments”
Now select the Methods tab in the MRI dialog.
Scroll through the list of methods and select “getByName”.
You should get a popup list of items in the main Reports folder. One of those items should be the name of the Folder where your report is stored. Select that item.
Scroll through the methods list and again select “getByName”. A new list should popup this time your report name should be on the list. Select that item.
If it hasn't occurred to you what needs to changed in your macro press <Ctrl> h and a new pane should open at the bottom of the MRI dialog. It displays the code used to access your report. You can copy this code into the clipboard.
In the IDE stop the macro execution. Paste the contents of the clipboard into your macro.
Finally, edit the “rp” assignment in include the inserted code.
You can either delete the lines of code used to access the MRI tool or better yet change them to comments in case you need them at some future date.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.4 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 574
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Problem loading a report

Postby Villeroy » Thu Aug 31, 2017 7:29 pm

Activate your database window.
Tools>Add-Ins>Mri. Now you see all properties and methods of the active document.
Maximize the MRI window.
Double-click property "ReportDocuments". Now you see all properties and methods of the reports collection.
Double-click method getByName and choose the name of the folder. Now you see all properties and methods of the folder.
Double-click method getByName and choose the name of the report. Now you see all properties and methods of the report.

Alternative path to the members of a folder:
Use the [<] button or the list box in order to go back to the ReportDocuments
Double-click method getByHierarchicalName and enter "Folder1/MyReport" (with actual names of folder and report)

Finally hit Ctrl+H and enjoy the code. It is also availlable in C++, Java and Python
Code: Select all   Expand viewCollapse view
Sub Snippet
  Dim oReportDocuments As Variant
  Dim oObj1 As Variant
  Dim oObj2 As Variant
  Dim oObj3 As Variant

  oReportDocuments = ThisComponent.getReportDocuments()
  oObj1 = oReportDocuments.getByName("Folder1")
  oObj2 = oObj1.getByName("qFiltered")
 
  oObj3 = oReportDocuments.getByHierarchicalName("Folder1/qFiltered")

REM added by Villeroy:
REM oObj2 is the same object as oObj3
REM which can be proved with a Basic function
print EqualUnoObjects(oObj2, oObj3)
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24584
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Problem loading a report

Postby arfgh » Thu Aug 31, 2017 9:47 pm

thx so much UnklDonald418 for such effort you did on your post :)
I go to mess with the MRI, now knowing how to start thx to you.
Surely will help me much with basic procedures, etc.

thx
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm


Return to Base

Who is online

Users browsing this forum: No registered users and 10 guests