Question

Locked

SQL Statement in VB6 Code

By belcredit ·
I thank all of you for your input. Unfortunately no suggestion workes.

I have created a query using VB6 Query builder which works when run from the Query builder but when placed in my code it produce the following error.

"syntax erroe in FROM CLAUSE"

Here is the Select statement which works in the Query builder.

SELECT tblInfo.fldSuit, tblPayments.fldSuit, tblInfo.fldRCR, tblPayments.fldPDate, tblPayments.fldPaid, tblPayments.fldBalance, tblPayments.fldCashier, tblPayments.fldRecNum, tblPayments.fldVchNum
FROM tblInfo INNER JOIN tblPayments ON tblInfo.fldSuit = tblPayments.fldSuit
WHERE tblPayments.fldSuit = Gsuit;

I know that the problem is in declairing "GSuit" as a string in the select statement. The syntax to do this is where I am falling down.


?To fill the Grid with data that matches the Value in cboPayCombo

Dim strSuit As String
strSuit = cboPayCombo.Text
strQuery = "SELECT tblInfo.fldSuit, tblPayments.fldSuit, tblInfo.fldRCR, tblPayments.fldPDate, tblPayments.fldPaid, tblPayments.fldBalance, tblPayments.fldCashier, tblPayments.fldRecNum, tblPayments.fldVchNum
FROM tblInfo INNER JOIN tblPayments ON tblInfo.fldSuit = tblPayments.fldSuit
WHERE tblPayments.fldSuit = Gsuit"

adoGrid.RecordSource = strQuery adoGrid.Refresh
dtgPayment.ReBind


Please if someone can show me the correct syntax I would be very happy. Thank you.

You can contact me direct at belcredit@yahoo.com

This conversation is currently closed to new comments.

12 total posts (Page 2 of 2)   Prev   01 | 02
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Check how strSuit is used

by kerry.millen In reply to SQL Statement in VB6 Code

Dim strSuit As String
strSuit = cboPayCombo.Text

"SELECT
tblInfo.fldSuit,
tblInfo.fldRCR,
tblPayments.fldPDate,
tblPayments.fldPaid,
tblPayments.fldBalance,
tblPayments.fldCashier,
tblPayments.fldRecNum,
tblPayments.fldVchNum,
tblPayments.fldSuit
FROM
tblInfo,
tblPayments

WHERE
tblInfo.fldSuit=tblPayments.fldSuit
AND
tblPayments.fldSuit = '" & strSuit & "'"

The last part of your WHERE clause is doing this:
tblPayments.fldSuit = 'strSuit'"

Since strSuit is not a literal string but a string variable, shouldn't you be doing this?

tblPayments.fldSuit=strSuit"

Back to Web Development Forum
12 total posts (Page 2 of 2)   Prev   01 | 02

Software Forums