Results 1 to 6 of 6

Thread: [RESOLVED] query problem using combo box

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [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 Attached Images  

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: query problem using combo box

    You are missing an equals ( = ) sign

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    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 & ""

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    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) & "'"

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: query problem using combo box

    Thank you.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width