[Solved] Problem with DLookup (Access2Base) in MySQL

Discussions about using 3rd party extension with OpenOffice.org
Post Reply
inizul
Posts: 8
Joined: Sat Aug 20, 2016 5:46 pm

[Solved] Problem with DLookup (Access2Base) in MySQL

Post by inizul »

When I execute de following code:

Code: Select all

Sub IPF_ActualizarDenominacionComponente ()
  Dim sCodigo as string
  Dim sDenominacion as string
  
  sCodigo=getValue("Forms!InformePreserieFicha!codigo") 
  sDenominacion=Application.DLookup("[Denominacion]", "[piezas]","[Codigo]='" & scodigo & "'")
  '             [Application.]DLookup(expression,       domain           [, criteria]             [, orderclause]))
  setValue("Forms!InformePreserieFicha!Componente.Value", sDenominacion)
End Sub 
The program ABORT (see atached image):

Code: Select all

SQL=SELECT TOP1 'Denominacion' AS 'TEMP48341' FROM 'piezas' WHERE 'Codigo'='K57M411200'
Is the SQL query correct? Or am I doing something wrong?

Database type: MySQL (JDBC) 5.7.11 x86
Database Engine: MyISAM
Server: 5.7.11 - MySQL Community Server (GPL)
LibreOffice: 5.1.4.2
Attachments
abort_dLookup.png
Last edited by Hagar Delest on Sun Aug 28, 2016 4:15 pm, edited 2 times in total.
Reason: tagged [Solved].
LibOffice 5.1.4.2 on Windows 7
inizul
Posts: 8
Joined: Sat Aug 20, 2016 5:46 pm

Re: Problem with DLookup (Access2Base) in MySQL

Post by inizul »

But this code work well

Code: Select all

Sub ActualizarDenominacionComponente()
' Busca en la tabla de piezas la denominación a partir del código
' Ejecuta: la actualización del registro
  Dim sCodigo as string
  Dim sDenominacion as string
  Dim oCodigo as Object
  Dim oFormulario as object
  Dim oControl
  Dim oRecordset as object

  set oFormulario=Forms("InformePreserieFicha")
  set oControl=oFormulario.Controls("codigo")
  sCodigo=oControl.Value
  Set oRecordset = Application.CurrentDb().OpenRecordset("SELECT [Denominacion] FROM [piezas] WHERE [Codigo]='" & sCodigo &"'")
  'msgbox "RecordCount: " & oRecordset.RecordCount
  sDenominacion=oRecordset.Fields(0).Value
  set oControl=oFormulario.Controls("Componente")
  oControl.Value= sDenominacion
  oRecordset.mClose
End sub
...
LibOffice 5.1.4.2 on Windows 7
JPL
Volunteer
Posts: 130
Joined: Fri Mar 30, 2012 3:14 pm

Re: Problem with DLookup (Access2Base) in MySQL

Post by JPL »

Hi Inizul,

indeed there is a bug in Access2Base/LO 5.1 caused by the fact that MySQL does not recognize the "SELECT TOP 1" syntax as HSQLDB does.

It has been corrected in LO 5.2 after its mention HERE.

Thanks.
JPL
Kubuntu 22.04 / LibO 7.5
Access2Base (LibO).
BaseDocumenter extension (LibO)
ScriptForge (LibO)
Documentation on https://help.libreoffice.org/latest/en- ... bPAR=BASIC
inizul
Posts: 8
Joined: Sat Aug 20, 2016 5:46 pm

Re: Problem with DLookup (Access2Base) in MySQL

Post by inizul »

Ups!!

Sorry for not correctly read the documentation :oops:

JPL: Thanks for the clarification.
LibOffice 5.1.4.2 on Windows 7
Post Reply