Results 1 to 6 of 6

Thread: Missing Operator

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    7

    Missing Operator

    hello!!! newbie here....i also have this problem. my code goes like this...

    vb Code:
    1. Private Sub cmdSearch_Click()
    2. Dim cn As New ADODB.Connection
    3. Dim rs As New ADODB.Recordset
    4.  
    5. cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\contact.mdb;Persist Security Info=False"
    6.  
    7. Set rs = cn.Execute("SELECT * FROM Table1 WHERE Contact ID = '" & txtContId.Text & "'")
    8.  
    9. DataGrid1.DataSource = rs
    10.  
    11. DataGrid1.Refresh
    12. End Sub

    what i want for this code is to search for a particular record that will be inputted in the txtContId.text and then show the other contents of that record in a table form in the datagrid1.

    but instead in gives an error "operator missing".

    Please help me....God bless

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

    Re: Syntax error (missing operator)

    You should create a New Thread for your question.

    Field name Contact ID contains a space, you have to surround it with square brackets:
    Code:
    "SELECT * FROM Table1 WHERE [Contact ID] = '" & txtContId.Text & "'"
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

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

    Re: Syntax error (missing operator)

    Quote Originally Posted by anhn
    You should create a New Thread for your question.
    Agree.

    Split into its own thread

    If you wish to contribute to the answer to someone else's question, then by all means, post in their thread.

    If, however, you have a question of your own, please create your own thread.

    Thanks.

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    7

    Re: Missing Operator

    Hi!

    I am very sorry if I did not follow the rules of the forum. its just that I was in a hurry and thought that my question will fit to the other thread since i am experiencing the same error in my program.

    thanx to anhn for replying to my question. I tried your suggestion and it genarated another error. It prompts "Data Member Not Found" and it's pointing to the "DataGrid1.DataSource = rs" statement in my above code.

    Hope you can give me another suggestion or anybody in this forum. and I also hope I am posting the right question in the right thread right now.

    Thanks again...God bless!

  5. #5
    Member
    Join Date
    Mar 2008
    Posts
    47

    Re: Missing Operator

    HEy Tagheuer34,

    try to add this line:
    cn.cursorlocation = adUseClient

    before this line:
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\contact.mdb;Persist Security Info=False"

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    7

    Re: Missing Operator

    thank you Krizaaa for giving me a suggestion with regards to my problem.

    But I already tried your suggestion and still it gave the same result.

    But thanks anyway!

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