Hi Alan,
As I understand it, what Robert is referring to is that with a form, it
is possible to have calculated fields and make a print out of one
record, e.g. by ensuring that all your form elements fit on one
printable page you can print out such a single record including the
calculated fields.
However, a more elegant solution is to use a report, and in order to do
this, you must base your report on a query with a filter parameter or a
prefiltered table. As you can't directly start a report from a macro
containing such a filter, using a prefiltered query table as the basis
for your report becomes a requirement in order to achieve this (and a
bit of macro programming).
This is basically what is described in the following section "Aufbau der
Filtertabelle", i.e. how to build a form (having an invisible ID field
with a prefiltered table that is created via the macro and then opens
the report
"Rechnung_gleiche_Ware_zusammengefasst_Kundenadressfeld"
I am assuming that the abovementioned report has some link to the
filtered content, as the macro code itself doesn't seem to contain any
explicit reference to the form/prefiltered data.
DIM oDoc AS OBJECT
DIM oDrawpage AS OBJECT
DIM oForm AS OBJECT
DIM oFeld AS OBJECT
DIM oDatenquelle AS OBJECT
DIM oVerbindung AS OBJECT
DIM oSQL_Anweisung AS OBJECT
DIM stSQL AS STRING
these are the variables for defining the objects to be used in the code.
oDoc = thisComponent
oDrawpage = oDoc.Drawpage
oForm = oDrawpage.Forms.getByName("MainForm")
oFeld = oForm.getByName("fmtID")
the above code gets the Form component of the Drawpage, and gets the
value of the form field "fmtID"
oDatenquelle = ThisComponent.Parent.CurrentController
If NOT (oDatenquelle.isConnected()) THEN
oDatenquelle.connect()
END IF
oVerbindung = oDatenquelle.ActiveConnection()
oSQL_Anweisung = oVerbindung.createStatement()
stSql = "UPDATE ""Filter"" SET ""Integer"" =
'"+oFeld.GetCurrentValue()+"' WHERE
""ID"" = TRUE"
oSQL_Anweisung.executeUpdate(stSql)
this code checks whether there is an active database connection from the
current controller parent and then builds a SQL update statement and
executes it
ThisDatabaseDocument.ReportDocuments.getByName(
"Rechnung_gleiche_Ware_zusammengefasst_Kundenadressfeld").open
the above code is then supposed to open the report named.
So, my assumption is that this named report contains some kind of
reference to the prefiltered table, otherwise I don't see how the data
is going to get retrieved. It also doesn't appear to go into detail as
to how the report is linked to the prefiltered data, unless that is
described elsewhere.
Alex