Results 1 to 4 of 4

Thread: Help With FROM clause

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    118

    Post

    I keep geting a error that says Syntax error in FROM clause. here is my code :Private Sub Data1_Reposition()
    Dim strSQL As String
    Dim strKey As String
    If Label5.Caption = "" Then
    strKey = "0"
    Else
    strKey = Label5.Caption
    End If
    strSQL = "SELECT * FROM Orders " & _
    "WHERE (CustID= """ & strKey & """);"

    Data2.RecordSource = strSQL
    Data2.Refresh
    DBGrid1.ReBind
    End Sub


    Thanks for any help

  2. #2
    Member
    Join Date
    Jul 1999
    Posts
    33

    Post

    It looks like your FROM clause is fine; my only advice is to double check to make sure your "& _" is all right (lame advice, I know, but I'm drawing a blank on that).

    One other thing, though, and please be advised that I am not the grand master of this stuff but I thought I'd point it out in case there is a problem later, it looks like your WHERE clause has some quotation mark problems. The first """ should be '", and the last should be "'.

    HTH
    Jonathan

  3. #3
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274

    Post

    Try to write your line in this way:
    Code:
    strSQL = "SELECT * FROM Orders WHERE CustID= '" & strKey & "'"
    Good Look!

    Ulises


    [This message has been edited by Tonatiuh (edited 08-19-1999).]

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    Here's a debugging tip for SQL commands (that you're having problems with in VB).

    In the immediate window, ? the string that holds your SQL query. Copy the returned value to the clipboard. Open a SQL window (I create queries to SQL Server and Access, mainly)and paste the query. Then run it.

    I've found that the error messages on the target can be more meaningful than in VB

    [This message has been edited by JHausmann (edited 08-19-1999).]

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