Dear fellow Base enthusiasts/,
weekend again and I have studied the sample files by Ratslinger (Thank you Ratslinger!) from this post: Base: Print Button
It gave me lots of inspiration. I try to make something similar (see the attached file).
- I made a filter table (tblSPL_Filter, which has only two fields: a primary ID, field type Boolean and an Integer field) to hold the number to a row of data (SPL document) to be printed.
- I made a push button in the frm_SPL form under subform PrintForm (Data content is tblSPL_Filter), the button is attached to a macro:
Option Explicit
Sub OpenReport
Dim oController As Object
Dim oReportDoc As Object
oController = ThisDatabaseDocument.currentController
if not oController.isconnected then oController.connect
oReportDoc = Thisdatabasedocument.reportdocuments.getbyname(“rptSPL”).open
End SubSub PrintCurrent
Dim oForm As Object
Dim oColumn As Object
Dim iField As Integer
Dim oSubForm As Object
Dim oController As Object
Dim oReportDoc As Object
oForm = ThisComponent.Drawpage.Forms.getByName(“MainForm”)
iField = oForm.getByName(“fmtSPL_ID”).Text
if oForm.isNew() Then
MsgBox “New Record - Cannot Print”
Exit Sub
End If
oSubForm = oForm.getByName(“PrintForm”)
oColumn = oSubForm.Columns.getByName(“Sel_SPL”)
oColumn.updateInt(iField)
oSubForm.updateRow()
oController = ThisDatabaseDocument.currentController
if not oController.isconnected then oController.connect
oReportDoc = Thisdatabasedocument.reportdocuments.getbyname(“rptSPL”).open
End Sub
which should displays the report (rptSPL).
Unfortunately I failed to make it work. I noticed that the filter table tblSPL_Filter won’t be updated when I click the push button (Print SPL test) on the frm_SPL form.
If I manually change the value of the field Sel_SPL in the filter table, then it works, i. e., when I clicked the push button the corresponding SPL document is displayed correctly.
One month ago I made something similar successful: LO Base how to print just one row data (in report) at a time
Not this time, I don’t know where I made mistakes. I really want to understand the whole mechanism of using filter table and macro to achive such function. Any insight and help will be very much appreciated.
And are there any other easier solutions to print a specific row of data (corresponding to a specific ID)? Anyone can introduce me any resources (ebooks, videos) on this topic (using filter table) for further learning? Thanks!!!
(LibreOffice 7.1,5.2, Mac OS X 10.16, HSQLDB)
Basetran_Repair.odb (51.5 KB)