SELECT "COD_CONTA" AS "CONTA", SUM ('DEBITO) AS "DEBITO", SUM ("CREDITO") AS "CREDITO" FROM "tMOVIMENTOS_CONTA" AS "tMOVIMENTOS_CONTA" WHERE "DATA_MOV" >= :DATAINICIAL AND "DATA_MOV" <= :DATAFINAL GROUP BY "COD_CONTA
I wanted to pass parameters from forms to the query.
Would somebody could help me?
Edit:
Last edited by Villeroy on Thu Jun 02, 2011 10:26 pm, edited 1 time in total.
Reason:added code tags
I wish there would be a less complicated answer to this, but I fear you won't be able to achieve this without macros. Here is an outline on how to do this (it is difficult to be more precise, because this depends on how you want to start the macro, button click, ...?)
Retrieve the connection from the active DataSource
Use the prepareCommand() method of the connection to create a prepared statement based on the query
Retrieve your two date values from the current record of the form
Bind these two variables to the place holders in the query (Note: Date parameters need to be of type "com.sun.star.util.Date" UNO structure: stmt.setDate(1,aBegin) and stmt.setDate(2,aEnd))
Execute the prepared statement to retrieve a result set
Iterate through the result set and use the getString() and getLong() to read the resulting fields into variables of your scripting language.
Using result of Queries has some OOo Basic code that might be good enough for you after some modifications.
I can give you some sample code, once you have decided to go the macro way. But be aware that you need some programming experience because most probably you will have to make some modifications to match it on you environment. And without experience (including debugging a macro) this will all be like chinese for you.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice