-
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
-
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
-
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).]
-
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).]