|
-
Aug 18th, 1999, 06:06 AM
#1
Thread Starter
Lively Member
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
-
Aug 18th, 1999, 03:46 PM
#2
Member
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
-
Aug 18th, 1999, 06:47 PM
#3
Hyperactive Member
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).]
-
Aug 18th, 1999, 10:45 PM
#4
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|