Frank Schönheit - Sun Microsystems Germany wrote:
Hi Ariel,
Well .... my idea here would be to have a report bound to a certain
query of the form SELECT ... FROM ... WHERE ..., and to modify this
query's WHERE clause to filter for the form's current record (e.g. to
SELECT ... FROM ... WHERE ( ... ) AND ID = <current_form_id>).
' get the SQL statement which uniquely identifies the current
' record
composer = createUnoService( _
"com.sun.star.sdb.SingleSelectQueryComposer" )
composer.setQuery( form.ActiveCommand )
composer.appendFilterByColumn( _
form.getColumns().getByIndex/Name( ... ) )
' not this should be a column which uniquely identifies
' the current record of the form, ideally a primary key
' If you have multiple records which *together* identify
' the current record, then do repeated appendFilterByColumn
' calls
sqlStatement = composer.getQuery()
' modify our query so it is now based on this statement
query = form.ActiveConnection.getQueries().getByName( <query_name> )
query.Command = sqlStatement
' execute the report
...
This is our of my head, so there might be errors in there, but I'd say
it should work along those lines.
Almost - the report reads the query from disk, so you have to update the
query definition in the odb file before you launch the report. Which
could be looked at as a feature I suppose in that the if you run the
report from the UI later you get the last settings from the form. Not to
mention is you base the original form on the same query...well.
Another route should be to use the filter settings available at the
report definition. This filter setting is then 'added' to the command
statement used by the report, this should then allows us to base the
report on a query or work just as well if it is based on a table. Then
execute the report without saving the definition and neither the
baseline query and report is altered.
Drew
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]