Ask Your Question

how to open Base reports based on queries in standalone

asked 2016-09-09 17:21:29 +0200

koolninja gravatar image

updated 2016-09-09 17:22:39 +0200

I made standalone of form's, its working properly but when same process used for Base reports based on queries,

its open only generate column names but no output queries loaded.

when open in design mode no opens found to load data.

show me correct and clear steps to do standalone for reports.

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted

answered 2016-09-09 17:51:48 +0200

updated 2016-09-09 20:00:38 +0200

I think it is not possible. See here:

Edit: corrected link.

If my answer helped you, vote it with ✔ and with ∧ (here on the left)

edit flag offensive delete link more

Comments respectfully, I miss the point of the link in relation to the question. Possibly an incorrect link?

Ratslinger gravatar imageRatslinger ( 2016-09-09 18:26:22 +0200 )edit

@Ratslinger Thank you, I corrected the link. gravatar ( 2016-09-09 20:02:47 +0200 )edit

answered 2017-02-19 06:50:20 +0200

Kridtbandit gravatar image

Make a query in the database and then a report on that query. connect sub main to an button action event.

OPENFORM("you report")
End Sub

Sub openForm(FormName as String) 
 Form_id= ThisComponent.Drawpage.forms.MainForm.getByName("Form_id").CurrentValue

   oContext = CreateUnoService("") 
   oFont = oContext.getRegisteredObject("you database") 
   dbForms = oFont.DatabaseDocument.ReportDocuments 
   oAConnection = oFont.getConnection("","") 
'this line rewrite the Queries' 
    oAConnection.queries.getByName("queries").Command = "SELECT ""queriesID""  Where ""queriesID"" = '"& Form_id &"'"

   Dim pProp(1) As New 
   pProp(0).Name = "ActiveConnection" 
   pProp(0).Value = oAConnection 
   pProp(1).Name = "OpenMode" 
   pProp(1).Value = "open" 

   oForm = dbForms.loadComponentFromURL(FormName, "_blank", 0, pProp()) 
End Sub
edit flag offensive delete link more


@Kridtbandit the first line of openForm makes no sense. There is no such property MainForm under ThisComponent.Drawpage.forms. It must be something specific to your form. Also, what is oAConnection.queries statement? Why another query when there is one already? Sorry but this routine is not making sense. It almost appears you have a form with a list of reports and are selecting one to be run.

Ratslinger gravatar imageRatslinger ( 2017-02-19 08:15:19 +0200 )edit

After some analysis I got it to work. First line of openForm (Form_ID = ...) is specific to what you are doing and it is totally not needed. Also not needed is oAConnection.queries... line. again something specific to you. With those two lines removed the routine works to run a report from a standalone form. In future eliminate or explain specifics to what code actually does. Otherwise, it's a nice item for the toolbox.

Ratslinger gravatar imageRatslinger ( 2017-02-19 08:34:49 +0200 )edit

answered 2016-09-14 01:55:21 +0200

Ratslinger gravatar image

@koolninja please start putting more information in your questions such as LO version and operating system. Without this it can be harder to answer (like in this one).

I did get a report to run from a standalone form using Xubuntu 16.04 & LO v5.2.0.4.

First the report must have been created and tested to work in your .odb file. The database must also be registered.

The key to this was noted in the link provided by which mentioned DB Doc Shortcut which I couldn't find. Today I ran across it (click here) while looking for something else. You download this and install as an extension (menu Tools->Extension Manager...). Once installed you need to run a macro which will create a desktop file. Again from menu Tools->Macros->Run Macro... then under MyMacros->DBDocShortCuts->ModMain run Main (in right panel). This will start a dialog. There are drop downs to make filling in easier. Select Database, Document Type, DB Document, (office & shortcut location already filled in - should be OK), Shortcut Type(I used Bash) and a Label (your choice). Then press Create Shortcut button. As a Test, double click the newly created item and the report should run.

Next you need to connect the push button on the standalone form to the newly created item. In my case it was similar to /home/MY_DIRECTORY/Desktop/ReportTest.bash This was inserted into the URL property on the push button. Tested the button and the report ran fine.

edit flag offensive delete link more


Made on the road, operating system and lo release notes I will remember.

Kridtbandit gravatar imageKridtbandit ( 2017-02-19 08:58:38 +0200 )edit

answered 2019-05-16 15:17:16 +0200

picozzo gravatar image

Hello, I tried the procedure by installing the extension. With OpenOffice 4.1.6 Windows 10 works well. With LibreOffice 6.2.3 Windows 10 does not work. When starting the macro libreoffice returns an error in line 156. Error: "Value or data type not allowed. Data types not matched". I work with LibreOffice and if the error could be solved, it would be great. Thanks and sorry for my English.

edit flag offensive delete link more


@picozzo This is not an answer. Should only be used to respond to original question. Instead use add a comment

Got Mint version to work by replacing all occurrences of #FileNum with FileNum (remove #)

Ratslinger gravatar imageRatslinger ( 2019-05-16 18:06:44 +0200 )edit

Sorry for the mistake. Thanks for the support, the macro now it works.

By performing this procedure, LibreOffice returns an error. """"" Next you need to connect the push button on the standalone form to the newly created item. In my case it was similar to /home/MY_DIRECTORY/Desktop/ReportTest.bash This was inserted into the URL property on the push button. Tested the button and the report ran fine. """""""""""

I translate the error: "file: // c: /Users.../ShortcutToPrintReport.bat" is not an absolute URL that you can switch to an external application for opening.

Where am I wrong? Thanks

picozzo gravatar imagepicozzo ( 2019-05-17 09:33:50 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-09-09 17:21:29 +0200

Seen: 749 times

Last updated: May 16 '19