OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[SOLVED] Open a report from a form button using a filter.

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
rancor
General User
General User


Joined: 21 Nov 2006
Posts: 28

PostPosted: Tue Jun 26, 2012 5:38 am    Post subject: [SOLVED] Open a report from a form button using a filter. Reply with quote

Hi,
I'm trying to figure out how to open a report from a Form (using a button/macro) such that the report opens with a filter based on what is selected on the form.
On my form I have a table called tbProjects. In that table is ProjID field. So if I have a particular project entry selected in the table I want to open my report (which is query driven) such that only entries with the ProjID selected in the form are showing. I'm able to open the report using:
Code:
ThisDatabaseDocument.ReportDocuments.getByName("MyReport").open

But, I don't know how to grab the current focused ProjID from the form. Nor do I know how to open the report using that selcted ProjID as a filter on the report. Any suggestions? I'm running LO3.4.3 which use the new report engine.

thanks


Last edited by rancor on Thu Jul 05, 2012 2:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Tue Jun 26, 2012 8:02 am    Post subject: Reply with quote

Hello

Maybe this can help you?
http://user.services.openoffice.org/en/forum/viewtopic.php?f=39&t=45263&p=209235&hilit=ReportDocuments#p209235

Maybe this can help you too.
http://user.services.openoffice.org/en/forum/viewtopic.php?f=100&t=36124

Romke
_________________
OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum
Back to top
View user's profile Send private message
rancor
General User
General User


Joined: 21 Nov 2006
Posts: 28

PostPosted: Thu Jul 05, 2012 8:13 am    Post subject: Reply with quote

getByName does not appear to have .filter method that I can apply to the new report engine. This link gives examples for opening forms with filters. If I try to apply to my case:
Code:
    oReport = ThisDatabaseDocument.ReportDocuments.getByName("MyReport")
    oReport.open
    oReport.filter="( ""tbProjects"".""ProjID"" = " & ProjectID & " )"
    oReport.ApplyFilter=True
    oReport.Reload()


I get basic runtime error property or method not found: filter.
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Thu Jul 05, 2012 9:15 am    Post subject: Reply with quote

Hello

You can do it in that way.

Follow the examples or stop.

Romke
_________________
OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum
Back to top
View user's profile Send private message
rancor
General User
General User


Joined: 21 Nov 2006
Posts: 28

PostPosted: Thu Jul 05, 2012 2:08 pm    Post subject: [SOLVE] Reply with quote

OK I see I was following the wrong example (Open_Forms_Filtered). This worked based on your openReport function and the example:
Code:

Sub OpenProjectReport (oEvent As Object)
   dim oButton,oForm
   dim oConnection,oReportsDocuments
   oButton=oEvent.source.model
   oForm=oButton.parent
   oConnection=oForm.Activeconnection
   oReportsDocuments=oConnection.parent.DatabaseDocument.ReportDocuments
   RptName = "MyReport"
   ProjID=oForm.getByName("ProjectTable").getByName("ProjID").value       
   Filter="( ""tbProjects"".""ProjID"" = " & ProjID & " )"
   openReport(oConnection, oReportsDocuments, RptName, Filter)
End Sub



Thanks for the help.
Back to top
View user's profile Send private message
rancor
General User
General User


Joined: 21 Nov 2006
Posts: 28

PostPosted: Fri Jul 06, 2012 10:57 am    Post subject: New Error Reply with quote

OK so now all was working well on one computer, then all other systems so far are giving this error:
Quote:
BASIC runtime error.
An exception occurred
Type: com.sun.star.io.IOException
Message: C:/lo-3-4/clone/compnents/package/sourc/xstor/xstorage.cxx:2625;.

when they get to this line:
Code:

oReportDesign=oReportsDocuments.loadComponentFromURL(aReportName ,"",0,aProp())

All are windows systems are running LO3.4.5.
Any ideas what is going on?
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Fri Jul 06, 2012 12:08 pm    Post subject: Reply with quote

Hello

I have no idea about your problem but it is possible that you not installed the sun/oracle report builder. As far I knew the code you use from the example is only working with the Sun/Oracle reportbuilder.

Romke
_________________
OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum
Back to top
View user's profile Send private message
rancor
General User
General User


Joined: 21 Nov 2006
Posts: 28

PostPosted: Fri Jul 06, 2012 1:02 pm    Post subject: Reply with quote

Yes I can open the full report no problem on all systems (I've tried 5 systems now).

It appears to be related to JRE. On the system that was working I have four versions of Java runtime listed. "Use a Java..." is selected but none of the versions listed are selected. Runs no problem.

I then try each one separately and I get the error. Now that I have done this there appears to be no way to get back to the state where none of the javas were selected such that the macro worked without error. I have tested JRE's from 1.6.0_04 to 1.7.0_04 none are working.

I have an Ubuntu 12.04 box but can't get reports to open (it's complaining about a missign librptlo file).
Back to top
View user's profile Send private message
rancor
General User
General User


Joined: 21 Nov 2006
Posts: 28

PostPosted: Fri Jul 06, 2012 1:33 pm    Post subject: Tail chasing Reply with quote

OK. I was wrong it appears to be a problem with file being readonly in all the test cases where it did not work. We keep the database frontend in a document vault (back end is MySQL) such that file is readonly unless you have the exclusive lock to it, which you should only need if you are modifying the frontend. So if the LO office file is readonly you can't open the report in Design mode. I'm guessing this is related to these lines:
Code:
   aProp(2).Name = "OpenMode"
   aProp(2).Value = "openDesign"

If I change the .Value to just "open" I get around that error but then I can't set the filter. So this is an inherent problem with having file be readonly.

Any suggestions? For example is there anyway to include a variable criteria in the driving query (like "=:projID") and then have the macro push that value when opening the report?
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Fri Jul 06, 2012 2:06 pm    Post subject: Reply with quote

Hello

I have the idea your problem is outside my knowledge as home user.

I don't know if the solution can be to do no update of the document. With the mediadescriptor you can set for noupdate
UpdateDocMode=0
http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/MediaDescriptor.html#FilterOptions

Romke
_________________
OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum
Back to top
View user's profile Send private message
rancor
General User
General User


Joined: 21 Nov 2006
Posts: 28

PostPosted: Fri Jul 06, 2012 2:34 pm    Post subject: Reply with quote

I'm not sure how to use the UpdateDocMode=0 that you point out. If this was a Form the .filter= and .ApplyFilter=True would work fine. Seems like that should be a built in feature, maybe I'll post a bug report on that.

Here is one truly horrible (clever but doesn't work for client server app) solution I found:
http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=26040
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group