Results 1 to 5 of 5

Thread: Simple SQL Statement

  1. #1
    Guest
    I'm trying to execute this simple SQL statement and I get this error

    Compile Error
    Expected: Line Number or Label or statement or end of statement

    Here is the sql statement I'm using

    Dim strSQL As String

    strSQL = "Select * From tblCompany"
    "Where cCompName Like '" & cmbCmpName.Text & "'"

    DatComp.RecordSource = strSQL
    DatComp.Refresh

    Not sure if I'm supposed to use the like or not. I left my SQL book at home and I don't work with it every day. So if some can help me out I would appreciate it.

    Thank You
    Ken Devorak

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Oshkosh, WI
    Posts
    163
    I'm not sure this it, but the 2 parts for your SQL statement aren't connected with a line continuation and a ampersand. ie

    strSQL = "Select * From tblCompany" & _
    "Where cCompName Like '" & cmbCmpName.Text & "'"


  3. #3
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    You'll also need a space between tblCompany Where such as

    strSQL = "Select * From tblCompany " & _
    "Where cCompName Like '" & cmbCmpName.Text & "'"




  4. #4
    Guest
    what is tblCompany and cCompName a variables?
    then your sql missing more then few &
    strSQL = "Select * From " & tblCompany & _
    " Where " & cCompName & " Like '" & cmbCmpName.Text & "*'"
    i you use Like then mayby you can use *

  5. #5
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987

    Talking Tip

    Just a tip. Use debug.print when working with strings because it is easy to forget things like spaces. :P :P
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

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