Macros to open a report from a button

Discuss the database features

Macros to open a report from a button

Postby whosdaman » Sun Mar 04, 2012 5:08 am

I need the code to open a report from a button. i used the code

Code: Select all   Expand viewCollapse view
Sub OpenMyReport(oEvent As Object)

Dim RptName as string

RptName = "FeeCalculation"
ThisDatabaseDocument.ReportDocuments.getByName(RptName).open

End Sub


this gives an error i,e, the object variable is not set and it points to this code

Code: Select all   Expand viewCollapse view
ThisDatabaseDocument.ReportDocuments.getByName(RptName).open
OpenOffice 3.3 Ubuntu 11.10
whosdaman
 
Posts: 12
Joined: Mon Feb 06, 2012 3:11 pm

Re: Macros to open a report frm a button

Postby RPG » Sun Mar 04, 2012 10:10 am

Hello

I think the thread [Example] OpenForm with macros can give you also the information about opening a report.

Romke
openSuse version of LibreOffice 4.1.5.3 stable on openSUSE 12.2
RPG
Volunteer
 
Posts: 1548
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Macros to open a report frm a button

Postby whosdaman » Sun Mar 04, 2012 11:16 am

That has nothing about opening reports via a button...... so that didnt really help but thanks anyway
OpenOffice 3.3 Ubuntu 11.10
whosdaman
 
Posts: 12
Joined: Mon Feb 06, 2012 3:11 pm

Re: Macros to open a report frm a button

Postby RoryOF » Sun Mar 04, 2012 11:23 am

If it tells how to open a report using a macro, you then need to search for how to link a macro to a button.
Apache OpenOffice 4.0.1 on Xubuntu 13.10 and Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 14353
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Macros to open a report from a button

Postby Villeroy » Sun Mar 04, 2012 5:38 pm

RPG wrote:Hello

I think the thread [Example] OpenForm with macros can give you also the information about opening a report.

Romke

No, in that thread I redirected someone to use stand-alone form documents without any macros. Unfortunately, this does not apply to reports which is one reason why I prefer spreadsheet reports.

The first message of this topic contains macro code to open a report with the hard coded name "FeeCalculation" stored in the same database document as the macro.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 12.04, Apache OpenOffice 4.x
User avatar
Villeroy
Volunteer
 
Posts: 17294
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macros to open a report from a button

Postby whosdaman » Mon Mar 05, 2012 4:12 am

could someone just please tell me why the error is coming and why the code is not working???

i know how to assign a macro to a button and i would like to know why the macros i posted is not working as it should
OpenOffice 3.3 Ubuntu 11.10
whosdaman
 
Posts: 12
Joined: Mon Feb 06, 2012 3:11 pm

Re: Macros to open a report from a button

Postby RoryOF » Mon Mar 05, 2012 6:48 am

Apache OpenOffice 4.0.1 on Xubuntu 13.10 and Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 14353
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Macros to open a report from a button

Postby DACM » Mon Mar 05, 2012 7:33 am

That code seems to work as long as you have a report name "FeeCalculation" (case sensitive). And the code is saved to your .odb file (i.e. not MyMacros).

Code: Select all   Expand viewCollapse view
Sub OpenMyReport '(oEvent As Object)
    RptName = "FeeCalculation"
    ThisDatabaseDocument.ReportDocuments.getByName(RptName).open
End Sub
AOO 4.0.x; LO 4.1.x; Windows 7 64-bit
Wizard: Automated 'split' HSQL database template; Warning: Avoid embedded databases
Soli Deo gloria
User avatar
DACM
Volunteer
 
Posts: 1069
Joined: Tue Nov 03, 2009 7:24 am

Re: Macros to open a report from a button

Postby whosdaman » Mon Mar 05, 2012 12:18 pm

Thank you DAMC that worked i saved the macros into MyMacros and when i shifted it into .odb file and it worked.

i wanted to ask one last thing that i have made a report that requires you to enter the student id is it possible to edit the macros such that it will take the student id value from the form text box
OpenOffice 3.3 Ubuntu 11.10
whosdaman
 
Posts: 12
Joined: Mon Feb 06, 2012 3:11 pm

Re: Macros to open a report from a button

Postby Villeroy » Mon Mar 05, 2012 12:59 pm

Yes, it is possible indeed.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 12.04, Apache OpenOffice 4.x
User avatar
Villeroy
Volunteer
 
Posts: 17294
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macros to open a report from a button

Postby whosdaman » Mon Mar 05, 2012 5:26 pm

could someone please tell me how to do this??

any sample code or anything......

Thanks in advance
OpenOffice 3.3 Ubuntu 11.10
whosdaman
 
Posts: 12
Joined: Mon Feb 06, 2012 3:11 pm

Re: Macros to open a report from a button

Postby RPG » Mon Mar 05, 2012 6:58 pm

Hello

You clearly did not study the second example but I have the idea that it is not good for you to work with macros. I think follow the way of Villeroy and try to do it without macros.

Romke
openSuse version of LibreOffice 4.1.5.3 stable on openSUSE 12.2
RPG
Volunteer
 
Posts: 1548
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Macros to open a report from a button

Postby Villeroy » Mon Mar 05, 2012 7:24 pm

As far as I know, it takes a macro to open embedded objects by push button. We get rid of this limitation when we open stand-alone documents by means of ordinary hyperlinks. Any office document can have forms attached.
There are no reports outside the Base document except for Calc sheets with linked import ranges. WIth a little bit of hand made column layout, page styles and cell styles Calc can be fine tuned to serve as additional report generator not as good looking as Writer documents but with a lot of extra functionality.

Loading reports and forms filtered by current form content is possible without macros if the filter criteria are stored in some filtering record. Search this forum for "power filtering" by user Arineckaig.

Filtering record sets by macros requires programming skills even when you copied the methods from existing code. The details depend on the exact data types and how to substitute parameters with programatic variables of appropriate types.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 12.04, Apache OpenOffice 4.x
User avatar
Villeroy
Volunteer
 
Posts: 17294
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macros to open a report from a button

Postby cazbym » Wed Mar 28, 2012 12:12 pm

I have managed to open reports using the DBDocShortCuts extension and using this to create a shortcut to a report and then assigning the shortcut .bat file to the execute event of a push button. It seems to work.
Windows XP
OOo 3.4.1
connected to
External HSQLDB 2.3.0 DB
cazbym
 
Posts: 37
Joined: Wed Apr 15, 2009 2:52 pm


Return to Base

Who is online

Users browsing this forum: No registered users and 4 guests