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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting this error in VB6 - Please Help

Status
Not open for further replies.

KMinor

MIS
Jun 7, 2001
3
US
Can someone please tell me why I keep getting this error when running this sql statement:
Invalid syntax near '.'.

SQL1 = "SELECT dbo.PAYROLLDB_EMP.ENAME, dbo.PAYROLLDB_EMP.DEPARTMENT, dbo.PAYROLLDB_JBDES.DESCRIPT" & _
"FROM dbo.PAYROLLDB_EMP INNER JOIN dbo.PAYROLLDB_JBDES ON SUBSTRING(dbo.PAYROLLDB_EMP.CURPOS,6,5) = SUBSTRING(dbo.PAYROLLDB_JBDES.JOBNUM,5)" & _
"WHERE [DEPARTMENT] = " & Depts.Text
 
Spacing. Your ".DESCRIPT" part and the "FROM" part don't have the required space character. There may be other space problems in your code so check the other lines as well.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Just as a pointer to you in the future, it is good practice to use message boxes or debug.print to display the value of such variables when you have an error.

on this case on debug mode you could do
debug.pring SQL1.

I would say from your post that the problem is to do with missing spaces before the "FROM" and also before the "WHERE".

I would also check that your last substring is correct (it may be).

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top