Hi Harvey,
how would this work for me, where I only want to create a SQL statement
as a string and execute it.
Mcro works with SQL-code, which has been saved in a field of a table.
Field in the table is called "SQL-Code". Table is datasource of a form.
A button in this form will start the code.
First needed object is executing a button in the form to start the
procedure.
If you will save all code directly in a macro you will need
→ a connection to the database
→ SQL code, which has been maskes with double doublequotes for
fieldnames and tablenames
→ var for creating a statement
→ execute the sql-code in this created statement
At which line of the macro the code stops for you?
Here a code from German Base Handbuch:
SUB ChangeData(oEvent AS OBJECT)
DIM oConnection AS OBJECT
DIM oForm AS OBJECT
DIM stSql AS STRING
DIM oSql_Statement AS OBJECT
DIM inValue AS INTEGER
oForm = oEvent.Source.Model.Parent
oConnection = oForm.activeConnection()
stSQL = oForm.getString(oForm.findColumn("SQL-Code"))
inValue = MsgBox("Should SQL-Code" & CHR(13) & stSQL & CHR(13) &
"be executed?", 20, "Execute SQL-Code")
IF inValue = 6 THEN
oSQL_Statement = oConnection.createStatement()
oSQL_Statement.execute(stSql)
END IF
END SUB
SQL-Code is part of a table. Field in the table is "SQL-Code". Table
is
datasource of a form. A button in this form will be enough to execute
the macro. You coud update, insert or delete rows by command
"execute".
Regards
Robert
--
Homepage: https://www.familiegrosskopf.de/robert
--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy