
Reset Button
Reset Button
I am new to Open Office and programming. My problem is that I have a great deal of text info in the records of a database. Users can select what data they require by ticking a a box which is part of the relevant record. This is then filtered using a query and presented as a Report. What I would love to do is to use a button to reset all of the selected boxes back to "False" to avoid confusion on the next selection and report generation. I have managed to do this using the Sql facility (Update -Set) but that would be too complicated of the users of my database Thanks in advance for any help received. 

OpenOffice 4 on Windows 10
-
- Volunteer
- Posts: 1566
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Reset Button
The Open Office API has a Statement Service for executing SQL statements via a macro.I have managed to do this using the Sql facility (Update -Set) but that would be too complicated of the users of my database
Place the following macro in the macro library for your database document
Code: Select all
Sub ExecuteSQLviaStmtServ
Dim Context
Dim DB
Dim Conn
Dim Stmt
Dim Result
Dim strSQL As String
FormUrl = ThisComponent.Parent.URL
Context=CreateUnoService("com.sun.star.sdb.DatabaseContext")
DB=Context.getByName(FormUrl)
Conn=DB.getConnection("","")
Stmt=Conn.createStatement()
REM note that any Quotation marks ” in the SQL statement must be doubled
REM ie Update “Table1” SET “checkBox1” = FALSE
REM would need to be strSQL = ”Update ”” Table1”” SET ”” checkBox1”” = FALSE”
strSQL = “Your SQL statement"
Result = Stmt.executeUpdate(strSQL)
Conn.close()
End Sub
Next right click on the Reset Button on your form and select Control to get to the Control Properties dialog.
Click on the Events tab and then on the ellipsis next to Approve action and complete the dialog to connect the button event to the macro.
Also note that for this to work your database must be registered.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11