It seems to me, based on what I’ve read here, in Andrew P’s book, etc., that this should work:
sub ClearSelectionComments
dim rstTemp as Object
sql = "SELECT * from comments WHERE select_box = 1"
set rstTemp = CurrentDB.OpenRecordset(sql)
if rstTemp.RecordCount > 0 then ' This is how you tell if no records were delivered
REM Do an update
sql = "UPDATE comments SET select_box = 0 WHERE select_box = 1"
DoCmd.RunSQL(sql)
endif
rem requery the form so it refreshes the screen
dim oForm as Object
Set oForm = getObject("Forms!comments")
oForm.Requery
oForm.Refresh
end sub
It runs without error. The SQL function works and clears the tick boxes in the underlying SQLite3 database. I verify this with DB Browser.
But the screen in LibreOffice BASE never updates. This is a simple form, with a table grid and a button called “Clear selection” which, when clicked, runs the macro above.
I tried doing OForm.SetFocus – no help. I tried doing:
dim ctrl as Object
set ctrl = getObject("Forms!comments!Comments_Grid")
ctrl.Requery
ctrl.Refresh
For that, I get: “Error #1527 (Method ‘Control.Requery’ not applicable in this context) occurred in a call to function ‘Control.Requery’”
I even tried selecting a specific field in the table grid.
dim ctrl as Object
set ctrl = getObject("Forms!comments!Comments_Grid!select_box")
ctrl.SetFocus
ctrl.Requery
ctrl.Refresh
And got the same error.
I spent several hours reading Andrew’s OpenOffice.org Base Macro Programming and OpenOffice.org Macros Explained. And the better part of a couple of days reading the Getting Started with BASE doc, and the BASE Handbook.
I even thought of opening the recordset under the form, iterating it and clearing the select_box flag from it. But the Access to Base doc says that the recordset and the form will be independent, so that would mean that doing it that way would indeed change it in the underlying table, but not in the form.
I’ve studied the API doc for LO Base for a few hours, and read enough about the interface oriented programming that is required to know that I don’t want to learn that for this small job, which is a quick-and-dirty app for a son of mine. I’ve done a good bit of VBA in MS Access in the past, where you do this with something like " Forms![MainForm]![subformName].Requery"
I’ve also been testing out using Python, with even worse luck, because you either have to know the large native API set, or just call Access2Base, in which case for something small like this you might as well use Access2Base.
I have this nagging feeling that I’m missing something obvious, because the Acess2Base doc sure seems to me to indicate that oForm.Requery ought to work.
Thanks in advance for any advice you can give.
Max
So