1 Attachment(s)
[RESOLVED] query problem using combo box
I have problem here.. my field name "Nama Penyakit" is text data type and I want to query from combo box. After getting the result I want to show the ID number for selected record in textbox. Why I get the error message like this?
Quote:
penyakittable.Open "Select * from penyakit where Nama Penyakit" & "' Combo1.List(Combo1.ListIndex)'", conpenyakit, adOpenDynamic, adLockOptimistic
Text34.Text = penyakittable.Fields("Penyakit id").Value & ""
Re: query problem using combo box
You are missing an equals ( = ) sign
Re: query problem using combo box
It still got same error message. Why?Field name is correct.
Quote:
penyakittable.Open "Select * from penyakit where Nama Penyakit =" & "' Combo1.List(Combo1.ListIndex)'", conpenyakit, adOpenDynamic, adLockOptimistic
Text34.Text = penyakittable.Fields("Penyakit id").Value & ""
Re: query problem using combo box
* Because filed name Nama Penyakit contains a space, you have to put it in brackets: [Nama Penyakit]
* What after "=" sign is wrong.
It should be:
Code:
"Select * from penyakit where [Nama Penyakit] = '" & Combo1.List(Combo1.ListIndex) & "'"
Re: query problem using combo box
Re: query problem using combo box
Quote:
Originally Posted by anhn
* Because filed name Nama Penyakit contains a space, you have to put it in brackets: [Nama Penyakit]
* What after "=" sign is wrong.
It should be:
Code:
"Select * from penyakit where [Nama Penyakit] = '" & Combo1.List(Combo1.ListIndex) & "'"
Ahhhh.....I missed that. Good catch! :thumb: