Print Report With Current Record

Getting your data onto paper - or the web - Discussing the reports features of Base

Print Report With Current Record

Postby macbeth » Tue Feb 02, 2010 3:19 am

Hi,
I have a form that shows 1 record at a time and I want to print the currently displayed record in a report from the form. Can this be done. Right now I have a button on the form that open a criteria form where I enter a parameter to print the currently displayed record. The criteria table is in the query with the main table. Clear as mud? Thank you!
OpenOffice 3.2 on Win Vista
macbeth
 
Posts: 61
Joined: Mon Nov 09, 2009 6:47 pm

Re: Print Report With Current Record

Postby OachKatz3L » Mon May 17, 2010 12:38 pm

Hello,
I'm looking for the answer to this question too (Print current report of a form).
Does anyone have an example or "how to" to point to ?
Thanks,
Oach!
Edit : SRB visibly uses tables or queries to build reports. Could someone confirm that if I'm looking for editing a current row of a form, I'll have to build a macro linking my row with a prepared report based on the queries and tables used by my form ?
OOo 3.2.0 SRB 1.2.0 / Windows XP SP2 (+ Mac OS X 10.5.8 )
User avatar
OachKatz3L
 
Posts: 4
Joined: Tue Apr 27, 2010 12:29 pm
Location: France

Re: Print Report With Current Record

Postby evwool » Thu May 20, 2010 10:09 am

I've attached a db to show you how it works. It uses Villeroy's idea of a Filter Table to filter the report via the query on which the report is based. In one form, the macro only opens the report, in the other form, the macro puts a value into the Filter Table and then opens the report.

Ask if anything doesn't make sense.
Attachments
EvsOrdersSimple.odb
(73.52 KiB) Downloaded 959 times
OpenOffice 3.1.1 on Windows XP and on Windows 7 Starter
evwool
Volunteer
 
Posts: 401
Joined: Fri Oct 09, 2009 9:40 pm
Location: UK

[Resolved] Print Report With Current Record

Postby OachKatz3L » Sat May 22, 2010 12:00 pm

Hi,
First macro is just simple & perfect :super:
Second is more complicated, but offers more ... still working on it
Thanks a lot.
Oach!
(PS :Will the former author edit this post to [Resolved])
OOo 3.2.0 SRB 1.2.0 / Windows XP SP2 (+ Mac OS X 10.5.8 )
User avatar
OachKatz3L
 
Posts: 4
Joined: Tue Apr 27, 2010 12:29 pm
Location: France

Re: Print Report With Current Record

Postby evwool » Sat May 22, 2010 4:25 pm

If you want any help making the second macro work, please say. It will help me, since my aim is to make my coding as transparent as possible so that it can be adapted easily.
That's why I haven't included any of the normal extras (error traps to make sure that the report isn't already open, for instance). It is possible that either the original author has already figured this out or he still needs a bit of help adapting the macro to his database.
OpenOffice 3.1.1 on Windows XP and on Windows 7 Starter
evwool
Volunteer
 
Posts: 401
Joined: Fri Oct 09, 2009 9:40 pm
Location: UK

Re: Print Report With Current Record

Postby Andy-Jordaan » Mon Jul 27, 2015 8:45 am

Hi Evwool,
This guide is Excellent and works well, However I am Struggling to get the Report to be in PDF format and not Writer

I have been following the guides of " Zizi64 " here
https://forum.openoffice.org/en/forum/v ... 20&t=78257

and "sainttomn" with "JohnV" here
http://www.oooforum.org/forum/viewtopic ... highlight=
and not getting the document in PDF

Here is what I have so far, using your "EvsOrdersSimple Database

Code: Select all   Expand viewCollapse view

REM  *****  BASIC  *****

Sub Main

End Sub

Sub OpenReport(oEvent As Object)
'EvsOrdersSimple-EW
Dim oReport As Object
Dim ReportName As String
'in this code, the query on which the report is based
'is  filtered when you use the Listbox and button in FrmOrders1
' to Filter your subform by customer
'all the code does is to open the report
ReportName = "RptCustomerStatement"
'the name of my report
oReport = ThisDatabaseDocument.ReportDocuments.GetByName(ReportName)
oReport.Open
End Sub

Sub UpdateTable(oEvent As Object)
'EvsOrdersSimple - EW
'this code reads OrdID in the selected record in the table grid
'then changes the LOrdID field in TblLookup
'using Update SQL
'QryRptOrder is filtered by LOrdID
'and RptOrder is based on this query
Dim ParentForm As Object
Dim ReadField As Object
Dim ReadFieldName As String
Dim LookupValue As Integer
Dim WriteField As String
Dim WriteTable As String
Dim PrimaryKeyField As String
Dim PKFieldValue As Integer
Dim MySQL AS String
Dim oReport As Object
Dim ReportName As String
Dim oStatement AS Object

ReportName = "RptOrder"
ReadFieldName = "OrdID"
'the field in my subform
WriteField = "LOrdID"
'the field in my filter table
WriteTable = "TblLookup"
'the name of my filter table
PrimaryKeyField = "LookID"
PKFieldValue = 0
'The value of LookID in the first
'record of my lookup table

ParentForm = oEvent.Source.Model.Parent
'the button which started this macro
'is in OrderForm (see Form Navigator)
ReadField = ParentForm.Columns.GetByName(ReadFieldName)
'ie OrdID in OrderForm
LookupValue = ReadField.Value
'read the current value of the OrdID
oStatement = ParentForm.ActiveConnection.CreateStatement
'Make an Action SQL statement to change the value
'of LOrdID in TblLookup
'ParentForm is a Sub-SubForm but that doesn't matter
MySql = "UPDATE """ & WriteTable & """"
MySql = MySql & " SET """ & WriteField & """=" & LookupValue
MySql = MySql & " WHERE """ & PrimaryKeyField & """=" & PKFieldValue
oStatement.Execute(MySql)
'Make the Action SQL work
oStatement.Close
'Tidy up
oReport = ThisDatabaseDocument.ReportDocuments.GetByName(ReportName)
'oReport.Open
'open the report newly filtered by LOrdID

REM START PRINT MACRO

REM
REM <a href="https://forum.openoffice.org/en/forum/viewtopic.php?f=20&amp;t=78257" title="https://forum.openoffice.org/en/forum/viewtopic.php?f=20&amp;t=78257">https://forum.openoffice.org/en/forum/viewtopic.php?f=20&amp;t=78257</a>
REM
'    Sub Expert_PDF     
    MyExportArea = "$A1:F200"
    PDF_URL = "File:///home/andy/Desktop/ReportName" 
'    print "After send to Desktop  step Two "
    Dim args2(1) as new com.sun.star.beans.PropertyValue
    Dim Arg(0) as new com.sun.star.beans.PropertyValue
    Arg(0).Name = "Selection"
    Arg(0).Value = oRange
    args2(0).Name = "FilterName"
    args2(0).Value = "calc_pdf_Export"
    args2(1).Name = "FilterData"
    args2(1).Value = Arg()

    ThisComponent.storeToURL(PDF_URL,args2())   

'   End Sub

REM END PRINT MACRO

End Sub


Any pointers would be appreciated
Ubuntu 16.04
Libre office 5.1
Andy-Jordaan
 
Posts: 26
Joined: Wed Jul 15, 2015 9:51 am
Location: South Africa


Return to Reporting

Who is online

Users browsing this forum: No registered users and 2 guests