Compilation error: expected: list separator or ) [Access/Vba]

Solved
Gnyss -  
 Gnyss -
Hello,

I have been encountering difficulties for a few days now, and I really need your help. Let me explain the situation:
Actually, I am just starting out with Access and I am trying to design an application, part of which will allow me to manage stock entries. But before getting there, what I would like to do first is to obtain the brand of the product and its quantity from the reference selected in a drop-down list.

Here is the VBA code:
Dim enrg As Recordset: Dim base As Database
Set base = Application.CurrentDb
Set enrg = base.OpenRecordset("SELECT marque, qteprod FROM produit WHERE idprod='"&Modifiable18.Value&"';", dbOpenDynaset)

qtemaj.Value = 0: qteac.Value = 0

enrg.MoveFirst
marque.Value = enrg.Fields("marque").Value
qteac.Value = enrg.Fields("qteprod").Value

qtemaj.SetFocus

enrg.Clone
base.Close

Set enrg = Nothing
Set base = Nothing

The problem is that the following error message appears every time I run the code: "compilation error: expected: list separator or )" and the cursor is positioned at the line:

Set enrg = base.OpenRecordset("SELECT marque, qteprod FROM produit WHERE idprod='"&Modifiable18.Value&"';", dbOpenDynaset)

Not knowing exactly where the problem lies, could you please help me!

Thank you in advance!!!

1 answer

f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
 
Bonjour,

There are missing spaces before and after the &
Set enrg = Base.OpenRecordset("SELECT marque, qteprod FROM produit WHERE idprod='" & Modifiable18.Value & "';", dbOpenDynaset)
0
Gnyss
 
Hello,

thank you for your response, I just modified the line by placing spaces before and after the &. But now another error message is displayed:
"runtime error '3464': incompatible data types in the criterion expression."
0
Gnyss
 
Thank you very much, I was able to solve the second problem and all of that thanks to you in part. In fact, idprod is of numeric type and yet in the expression, I had put quotes around Modifiable18 as if it were a string.

Thanks again! :-)]
0