Problem with the query

Hi,
I did get the attached error, due to the last line, in the following. why?

Option Explicit
Public Const HOST_LIB_DB As String = ""
'Public Const HOST_LIB_EQ As String = "KFILJKB"
'Public Const HOST_IP As String = "192.255.10.49"
Public Const HOST_LIB_EQ As String = "KFILJK1"
Public Const HOST_IP As String = "192.255.1.5"
Public HOST_UID As String
Public HOST_PWD As String
Const TBL_FM As String = "SAPF"
Public Const SQL_TIMEOUT As Integer = 120 ' sec
Public Function IS5ConnectionString() As String
    IS5ConnectionString = "PROVIDER=IBMDA400;" & _
                          "DATA SOURCE=" & HOST_IP & ";" & _
                          "USER ID=" & HOST_UID & ";" & _
                          "PASSWORD=" & HOST_PWD & ";" & _
                          "FORCE TRANSLATE=1;"
End Function
Sub Refresh_File()
    ...
    
    strCNT = IS5ConnectionString()
    Set cn = CreateObject("ADODB.Connection")
    cn.ConnectionTimeout = SQL_TIMEOUT
    cn.Open strCNT
    
    strSQL = "SELECT SAAB,SAAN,SAAS,SAAPP,SABRNM,c.scact,SAPOD,SAPBR,SAPSQ,SAVFR,SADRF,SATCD,SACCY,SAAMA FROM " & HOST_LIB_EQ & "." & TBL_FM & " a," & HOST_LIB_EQ & "." & "tipf t where length(ltrim(rtrim(cast(SAPOD as char(12)))))=7 and ltrim(rtrim(substring(ltrim(rtrim(cast(SAPOD as char(12)))),3,5)))=substring(tisctl,137,5) and ltrim(rtrim(SACCY))='USD'"

    Set rs = CreateObject("ADODB.Recordset")
    rs.Open strSQL, cn, adOpenForwardOnly, adLockReadOnly, adCmdText
    ...

Open in new window

tt12.png
LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tigin44Commented:
replace your query with this one

    strSQL = "SELECT SAAB,SAAN,SAAS,SAAPP,SABRNM,scact,SAPOD,SAPBR,SAPSQ,SAVFR,SADRF,SATCD,SACCY,SAAMA FROM " & HOST_LIB_EQ & "." & TBL_FM & " a," & HOST_LIB_EQ & "." & "tipf t where length(ltrim(rtrim(cast(SAPOD as char(12)))))=7 and ltrim(rtrim(substring(ltrim(rtrim(cast(SAPOD as char(12)))),3,5)))=substring(tisctl,137,5) and ltrim(rtrim(SACCY))='USD'"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tigin44Commented:
you have used  "c.scact" to reference a column but the the table alias "c" is not used so that causes the error. when remove it from the query as in my previous post it would run without error.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.