In a database of mine a very convenient way to execute some operations is by
running a small series of SQL statements.

 

As Base has no direct way to run a text file of SQL statements I asked on
Ask Libre Office and was given code in Basic that would read and execute a
file of SQL.

 

The first few lines of code are shown below

 

REM  *****  BASIC  *****

rem Option Explicit

 

Sub DoSQL

 

rem how to read text file

rem https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=33009

rem how to execute sql 

rem
http://ask.libreoffice.org/en/question/21205/libreofficebase-how-to-execute-
sql-from-basic-script/

rem check database connection

DIM txtfile AS STRING

DIM f1 AS INTEGER

DIM s AS STRING

DIM oStatement AS OBJECT

 

MsgBox("Code started")

if IsNull(ThisComponent.CurrentController.ActiveConnection) then

     ThisComponent.CurrentController.connect

endif

 

If I run this from the macro menu it runs perfectly.

 

However if I create blank form with just one button and set the properties
of that button to

run the macro it fails at the line

 if IsNull(ThisComponent.CurrentController.ActiveConnection) then

 with the error message

 "BASIC runtime error.

Property or method not found: ActiveConnection."

 

Can anyone help me please?

 

My final objective would be a form with 3 or 4 buttons each of which would
execute a different file of SQL

 

Regards

 

Allan

 

__

Allan Newton

Optical System Design

 


-- 
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Reply via email to