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

SQL query and error

Status
Not open for further replies.

03021979

Vendor
Feb 23, 2006
35
PL
I have sql query like this:

StrSqlTest = "SELECT OEP65.CUSN65,OEP65.DTIN65,OEP845L2.TENT45,OEP45.ONAM45, OEP45.OAD445, OEP45.OAD545,OEP040.SVIA40, OEP65.INVN65,OEP65.CUSO65, SQP608.ICAT08,OEP040.CORD40,OEP65.ORDN65,INP40.TLIN40,OEP70.LQTY70,OEP70.DGRP70,OEP70.DGRP70, PARTS.PGMN35,PARTS.PDES35, " _
& " INU056. XPIF56, INU056.XDIF56, INU056. WNET56,INP056.IDMD56,OEP845L2.IPNR45, OEP65.CURN65, OEP65.CURC65, OEP65.CURT65" _
& Chr(13) & "" & Chr(10) & _
"FROM EUROPEAN.TVSPF00.OEP65 OEP65, EUROPEAN.TVSPF00.OEP040 OEP040, EUROPEAN.TVSPF00.OEP065 OEP065, EUROPEAN.TVSPF00.INP056 INP056, EUROPEAN.TVSPF00.INU056 INU056, EUROPEAN.TVSPF00.OEP70 OEP70, " _
& " EUROPEAN.TVSPF00.PARTS PARTS, EUROPEAN.TVSPF00.OEP45 OEP45, EUROPEAN.TVSPF00.OEP845L2 OEP845L2, EUROPEAN.TVSPF00.INP40 INP40,EUROPEAN.TVSPF00.SQP608 SQP608 " _
& Chr(13) & "" & Chr(10) & _
"WHERE OEP65.CONO65 = OEP065.CONO65 AND OEP65.INVN65 = OEP065.INVN65 AND " _
& " OEP65.CONO65 = OEP70.CONO70 AND OEP65.INVN65 = OEP70.INVN70 AND " _
& " OEP70.CONO70 = PARTS.CONO35 AND OEP70.CATN70 = PARTS.PNUM35 AND " _
& " OEP65.CONO65 = OEP45.CONO45 AND OEP65.ORDN65 = OEP45.ORDN45 AND " _
& " OEP65.CONO65 = INP056.CONO56 AND OEP65.ORDN65 = INP056.ORDN56 AND OEP65.DESN65 = INP056.DESN56 AND " _
& " OEP65.CONO65 = INU056.CONO56 AND OEP65.ORDN65 = INU056.ORDN56 AND OEP65.DESN65 = INU056.DESN56 AND " _
& " OEP65.CONO65 = OEP845L2.CONO45 AND OEP65.ORDN65 = OEP845L2.ISHO45 AND OEP65.DESN65 = OEP845L2.IDNS45 AND " _
& " OEP65.CONO65 = OEP040.CONO40 AND OEP65.ORDN65 = OEP040.ORDN40 AND " _
& " OEP040.CONO40 = INP40.CONO40 AND OEP040.ORDN40 = INP40.TREF40 AND " _
& " OEP70.CONO70 = SQP608.CONO08 AND OEP70.CATN70 = SQP608.PNUM08 AND " _
& " OEP65.CONO65='88' AND INP40.TLNO40 = 2 AND INP40.USGC40 = 'I' AND " _
& " ((OEP65.INVN65 Between " & (Cells(2, 1).Value - 160) & " And " & Cells(2, 1).Value & " ) AND (OEP65.INVN65 NOT LIKE 'T%%%%%%')) ORDER BY OEP65.INVN65 DESC"


Sometimes when special records are detected, VB gives an SQL error. If I use ON ERROR GOTO ERROR_HANDLE and ERROR_HANDLE contains msgbox with information about this and exit sub statement, will it work?
 
It should work.

So, you don't want to know how to fix the error?
If you do - please state what eror you are getting.

---- Andy
 
This SQL query is to get orders invoiced in AS/400. Invoiced are numbered: 06..... but sometimes invoices like T...... are generated and I don't know exactly how to add them or exclude. I thought that (OEP65.INVN65 NOT LIKE 'T%%%%%%') would do that but if a T...... invoice is generated by AS/400 this SQL query gives an error (sql query is highlighted in yellow in VB). Invoice number is stored in all databases beginning with OEP but even if I add exlusion-condition for all of them and T invoice is generated, sql query doesn't work. If no invoice among the last 160 generated begins with T, it's all ok.. I don't remember the error state 'cos I don't have AS/400 at home:/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top