Sep 26th, 2007, 04:56 AM
#1
Thread Starter
Frenzied Member
[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?
penyakittable.Open "Select * from penyakit where Nama Penyakit" & "' Combo1.List(Combo1.ListIndex)'", conpenyakit, adOpenDynamic, adLockOptimistic
Text34.Text = penyakittable.Fields("Penyakit id").Value & ""
Attached Images
Sep 26th, 2007, 05:40 AM
#2
Re: query problem using combo box
You are missing an equals ( = ) sign
Sep 26th, 2007, 06:11 AM
#3
Thread Starter
Frenzied Member
Re: query problem using combo box
It still got same error message. Why?Field name is correct.
penyakittable.Open "Select * from penyakit where Nama Penyakit =" & "' Combo1.List(Combo1.ListIndex)'", conpenyakit, adOpenDynamic, adLockOptimistic
Text34.Text = penyakittable.Fields("Penyakit id").Value & ""
Sep 26th, 2007, 06:17 AM
#4
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) & "'"
Sep 26th, 2007, 06:22 AM
#5
Thread Starter
Frenzied Member
Re: query problem using combo box
Thank you.
Sep 26th, 2007, 07:03 AM
#6
Re: query problem using combo box
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!
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width