0

I'm trying to make a prepared query based on the value in a field in my form in libreoffice basic.For this, I created a macro. But it returns an error on the query line saying

BASIC syntax error. Unexpected symbol: oInstruction_SQL

Sub concatMotherName

Dim oSourceDonnees As Object
Dim oConnexion As Object
Dim stSql As String
Dim oResultat As Object

oSourceDonnees = thisComponent.Parent.dataSource
oConnexion = oSourceDonnees.getConnection("","")
oInstruction_SQL = oConnexion.createStatement()
Dim valueData As String
Dim dateLabel As String

valueData = ThisComponent.Drawpage.Forms.getByName("Form").getByName("id_mother_label").getCurrentValue()
stSql = "SELECT NOM_MERE FROM ""T_MOTHER"" WHERE ""NUM_MOTHER"" = ?" _
oInstruction_SQL = = oConnection.prepareStatement(stSql)
oInstruction_SQL.setString(1, valueData)
oResultat = oInstruction_SQL.executeQuery(stSql)
If Not IsNull(oResultat) Then
   oResultat.Next()
   MsgBox oResultat.getString(1)
End If
End Sub

1 Answer 1

1

There are two syntax problems. The first is the _ after the query string, which indicates that the next line is a continuation of that one. It's not a continuation, so remove it.

The second error is on the next line: = =.

When these errors are fixed, the code compiles successfully.

Sign up to request clarification or add additional context in comments.

1 Comment

oh my god I didn't saw that...thank you so much !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.