Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Syntax error in from statement" while using SQL in VB6

Status
Not open for further replies.

joeconway

Technical User
Feb 19, 2007
4
GB
i have a very simple couple of lines of code:

sql = "SELECT Itemid FROM [tblstock]; WHERE itemid = txtitemid.text"
adostock.RecordSource = sql
adostock.Refresh


and i keep getting the error in the subject line. I really can't understand the problem because i don't see what else i could put in.

any help would be really appreciated
 
sql = "SELECT Itemid FROM [tblstock] WHERE itemid = " & txtitemid.text

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
As a hint for the future
Code:
sql = "SELECT Itemid FROM [tblstock]; WHERE itemid = txtitemid.text"
[COLOR=red]Debug.Print sql[/color]
adostock.RecordSource = sql
adostock.Refresh

Would have quickly shown you where the error lay! (I virtually always do this when building SQL dynamically to make sure the the SQL string is built properly)

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top