I have a form where a field Startdatum is formatted as DD-MM-YYYY, I now want to insert the data on display in the form into another table which has a similar named and formatted field
The macro code I puzzled together is:
Sub insertarch Dim DatabaseContext As Object Dim DataSource As Object Dim opand as object Dim olid as object Dim spand as integer Dim slid as integer Dim sstartdat as date Dim oForm as object Dim oConn as object Dim oQuery as object oForm = ThisComponent.Drawpage.Forms.getByName("MainForm") opand = oForm.getByName("fmtPandidnr") olid = oForm.getByName("fmtLidnr") ostartdat=oForm.getbyname("fmtStartdat") spand = opand.getCurrentValue() slid = olid.getCurrentValue() sstartdat=ostartdat.getCurrentValue() DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext") DataSource = DatabaseContext.getByName("volks") Rem My DB name oConn = DataSource.getConnection("","") oQuery = oConn.CreateStatement() SQL = "INSERT INTO ""Pandenarchief"" (""pandidnr"",""lididnr"",""Startdatum"") values ('" & spand & "','" & slid & "','"& sstartdat &"')" oQuery.executeUpdate(SQL) REM EVENT.SOURCE.ACTIVECONNECTION.Parent.flush End Sub
When I run that I get an error: Conversion error from string '00:00:00" but as far as I can see, all involved have been defined as dates, not time or datetime. Where do I go wrong?
[Edit - Opaque] Changed code to pre-formatted text for better readability