LibreOffice 7.0.4.2 on Linux Mageia 7 and Windows 10, both fully updated.
The macro below has been working with previous versions of LO, but now fails
Sub insertarch
Dim DatabaseContext As Object
Dim DataSource As Object
Dim opand as object
Dim olid as object
Dim ostartdat as object
Dim spand as integer
Dim slid as integer
Dim sstartdat as String
Dim oForm as object
Dim oConn as object
Dim oQuery as object
oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
olid = oForm.getByName("fmtLidnr")
opand = oForm.getByName("fmtPandidnr")
ostartdat=oForm.getbyname("fmtStartdat")
spand = opand.getCurrentValue()
slid = olid.getCurrentValue()
sstartdat=ostartdat.getCurrentValue()
theDay = MID(sstartdat, 1, 2)
theMonth = MID(sstartdat, 4, 2)
theYear = MID(sstartdat, 7, 4)
goodDate = theYear & "-" & theMonth & "-" & theDay
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource = DatabaseContext.getByName("volks") Rem My DB name
oConn = DataSource.getConnection("","")
oQuery = oConn.CreateStatement()
msgbox ("sstartdat",0,"Datumwaarde")
If goodDate = "--" Then
SQL = "INSERT INTO ""Pandenarchief"" (""pandidnr"",""lididnr"") values ('" & spand & "','" & slid & "')"
oQuery.executeUpdate(SQL)
Else
SQL = "INSERT INTO ""Pandenarchief"" (""pandidnr"",""lididnr"",""Startdatum"") values ('" & spand & "','" & slid & "','"& goodDate &"')"
oQuery.executeUpdate(SQL)
Endif
REM EVENT.SOURCE.ACTIVECONNECTION.Parent.flush
End Sub
On Linux it stops after the line “oForm = ThisComponent.Drawpage.Forms.getByName(“MainForm”)” with error NoSuchElementException. Switching the lines that follow between each other makes no difference.
On Win10, it goes on, but throws a formatting erro on the second sql Insert (thus after the “else” clause) . The error is "conversion error from string -01-43. The date field in the form reads 01/01/18. This seems like it takes again the date as a number. The code to get the gooddate I got from another question on the forum here some time ago.
[Edit - Opaque] Formatted code as preformatted text for readability