Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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