MariaDB 10.11.0
Version: 7.4.2.3 (x64) / LibreOffice Community
Build ID: 382eef1f22670f7f4118c8c2dd222ec7ad009daf
CPU threads: 16; OS: Windows 10.0 Build 22621; UI render: Skia/Vulkan; VCL: win
Locale: en-GB (en_GB); UI: en-GB
Calc: CL
Windows 11
|Processor|AMD Ryzen 9 5900HX with Radeon Graphics 3.30 GHz|
|Installed RAM|32.0 GB (31.4 GB usable)|
|Device ID|83E8E3B7-1CFE-404B-8A70-4C7F14FDFBCE|
|Product ID|00330-50955-86349-AAOEM|
|System type|64-bit operating system, x64-based processor|
New poster, not a DBA by any means and a real novice at macros.
I have a simple database consisting of 2 tables.
From a form I am able to put data into one of the tables but when I have all the data (4 fields) I would lie to copy it from on table to the other.
The source table is just used to gather the data and not to store it.
The following code runs fine from the Execute SQL Statment window, but I can’t get it to work in a macro.
INSERT INTO tbl_shooting_record (membership
, calibre
,type
,serial_number
) SELECT membership_number
, calibre
,type
,serial_number
FROM tbl_filter_members
WHERE ID
= 1 AND membership_number
!= 0
I have looked at:
https://ask.libreoffice.org/t/run-sql-in-the-current-base-database/47965
but I can’t get it to work, I tried al options, the line I used there was:
oStatement.execute(“INSERT INTO ““tbl_shooting_record”” (”“membership”", ““calibre””,"“type”","“serial_number”") SELECT ““membership_number””, ““calibre””,"“type”","“serial_number”" FROM ““tbl_filter_members”” WHERE ID = 1 AND ““membership_number”” != 0 ")
The layout of my form is shown in the attached photo. I’m using Push Button 2 to run the macro.
When I press the button the mouse does the spinning thing, but I can’t see anything happening and if I look into the destination table it hasn’t been updated.
Thanks for any help.
EDIT
I’ve just seen a post saying that I should be using back tick and not double quotes so I updated my line to:
oStatement.execute("INSERT INTO tbl_shooting_record
(membership
,calibre
,type
,serial_number
) SELECT membership_number
,calibre
,type
,serial_number
FROM tbl_filter_members
WHERE ID = 1 AND membership_number
!= 0 ")
But still nit updating.