question about Base-Handbuch passage

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

Not quite sure how all of the discussion below managed to end up off
list, but anyway, for the record :

Hi :slight_smile:
If it's difficult to follow the instructions then it might just confuse
people. Technically working is one thing but being clear and easy to
follow is quite another.

Two good people (who normally find it easy to follow instructions, and
to write/translate them) have struggled to translate this bit. If they
couldn't cope with it then normal users, who are struggling anyway,
might find it tooo much to cope with.

It sounds like a "nice to have" rather than being crucial.

If it can be done reasonably quickly then great but there's no point
pouring tons of effort into it is there?
Regards from
Tom :slight_smile:

And my reply to Tom's comment would be :

Hi :slight_smile:
If it's difficult to follow the instructions then it might just confuse
people. Technically working is one thing but being clear and easy to
follow is quite another.

It isn't difficult to follow, what is no doubt missing from the current
text is a direct reference to the name of the example database file, so
that the user knows which one to open and play about with to see that,
and how, it works.

1) Open the file Beispiel_Bericht_Rechnung.odb

2) Activate Macros

3) Click on Reports in the left hand pane

4) Double-click on the report named

Rechnung_gleiche_Ware_zusammengefasst_Kundenadressfeld

5) If you want to inspect the macro, go to Tools > Macros > Manage
Macros > LibreOffice Basic

6) Click on Beispiel_Bericht_Rechnung.odb > Standard > Module1

7) Select Filtern_und_Drucken, then "Edit"

Considering that other guides in the series deal with using macros, that
is hardly rocket science for a guide of this type, and is in keeping
IMHO with the general level of expertise promoted.

Alex