If setting the Filter structure dynamically is not possible, then I will probably use SQL commands to dynamically create a table based on the changing query parameters and create the report off of this table. This approach is a bit more work and problems may arise when I go to a multi-user environment. Then I would have to ensure multiple users are not attempting to create reports at the same time. Therefore, setting the Filter structure seems the wisest path to a workable solution.
Some specifics if needed
Application: Printing medication prescriptions
Query pulls patient demographics and specifics about the prescription/s
Main variables that need to change dynamically
Medical record number: MRN
New Rx that needs to be output: RxNow
Rx Output: printer, fax, electronic, etc.
Once the user chooses the Rx's that need to be output, they select a button. This calls the code. I need to filter on MRN, RxNow and then will need to run the code one or more times based on where the output is going. I would run one report and send all current Rxs that are supposed to be printed to the selected printer, then run again and select the Rxs going out by Fax, etc.
I think I can create the code to at least run the Report and then print. I am stuck at the Filter part.
Any and all help is greatly appreciated!
Code to Open Report
Code: Select all
'Function OpenReport(RptName As String) As Object
Function OpenReport() As Object
Dim Context As Object
Dim DBDoc As Object
Dim Conn As Object
Dim DB As Object
Dim Report As Object
Dim Args(1) As New com.sun.star.beans.PropertyValue
Dim RptName As String ' *** temporary variable until call function after testing done
RptName = "RxPrintRPT2"
Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
Context = CreateUnoService ("com.sun.star.sdb.DatabaseContext")
DB = Context.getByName("DS_Pts090714")
Conn = DB.getConnection("","")
DBDoc = DB.DatabaseDocument
Args(0).Name = "ActiveConnection"
Args(0).Value = Conn
Args(1).Name = "OpenMode"
Args(1).Value = "open"
OpenReport = DBDoc.ReportDocuments.LoadComponentFromURL(RptName, "_blank", 0, Args())
Mri DBDoc
msgbox "DBDoc"
Mri OpenReport
msgbox "OpenReport"
End Function