Avatar of cacha18cr
cacha18cr
Flag for Costa Rica asked on

What does mean

I'm trying to take data from AS400 and using a VBA Macro in excel refresh a qry. But when the refreshment table excel gives me the following error
Error
Attached macro

Sub Actualizar()
   
    vBarco = Trim(Sheets("Menu").Range("D10"))
    vViaje = Trim(Sheets("Menu").Range("D11"))
    vLiner = Trim(Sheets("Menu").Range("D12"))
    vPais = Trim(Sheets("Menu").Range("E13"))
   
    Sheets("DTLTrace").Select
    Range("A1").Select
    With ActiveWorkbook.Connections("BarcoViajeDestino").ODBCConnection
        .BackgroundQuery = False
        .CommandText = Array("SELECT  FLTMRES.CNMCTE as Contenedor , FLTMMAN.CNMCTP as Prefijo, SCENEM as Embarque " _
            , ", FLTMMAN.ORFCOD as Empacadora " _
            , ", FLTMCNT.CNMFEH AS FechaLlegada " _
            , ", FLTMCNT.CNMFEH AS HoraLlegada " _
            , ", FLTMCNT.CNMLCH as  MatriculaChasis, FLTMCNT.CNMSLL as SelloLlegada " _
            , " FROM DOLDATTRC.FLTMRES FLTMRES,DOLDATTRC.FLTMMAN FLTMMAN,DOLDATTRC.FLTPPROD FLTPPROD,DOLDATTRC.FLTEEMBA FLTEEMBA," _
            , " DOLDATTRC.FLTMCNT FLTMCNT, DOLDATTRC.FLTFORIG FLTFORIG, DOLDATTRC.FLTESHIP FLTESHIP, DOLDATTRC.FLTFFINC FLTFFINC, " _
            , " DOLDATTRC.FLTESCHE FLTESCHE, DOLDATTRC.FLTFENTI FLTFENTI, DOLDATTRC.FLTMTDES FLTMTDES,DOLDATTRC.FLTEPORT FLTEPORT" _
            , " WHERE FLTMRES.PAFCOD = FLTMMAN.PAFCOD AND FLTMRES.FIFCOD = FLTMMAN.FIFCOD AND FLTMRES.ORFCOD = FLTMMAN.ORFCOD" _
            , " AND FLTMRES.MAMDOC = FLTMMAN.MAMDOC AND FLTMRES.PAFCOD = FLTPPROD.PAFCOD AND FLTMRES.PRPNKN = FLTPPROD.PRPNKN " _
            , " AND FLTMRES.SHECOD = FLTEEMBA.SHECOD AND FLTMRES.EMENVI = FLTEEMBA.EMENVI AND FLTMRES.PAFCOD = FLTFORIG.PAFCOD " _
            , " AND FLTMRES.DEMORG = FLTFORIG.ORFCOD AND FLTMRES.SHECOD = FLTESHIP.SHECOD AND FLTMMAN.MAMPTO = FLTEPORT.POECOD " _
            , " AND FLTMRES.PAFCOD = FLTMCNT.PAFCOD AND FLTMRES.CNMCTP = FLTMCNT.CNMCTP AND FLTMRES.CNMCTE = FLTMCNT.CNMCTE " _
            , " AND FLTMRES.FIFCOD = FLTMCNT.FIFCOD AND FLTMRES.MAMDOC = FLTMCNT.CNMDOC AND FLTMRES.PAFCOD = FLTFFINC.PAFCOD " _
            , " AND FLTMRES.DEMFIC = FLTFFINC.FIFCOD AND FLTMRES.SHECOD = FLTESCHE.SHECOD AND FLTMRES.EMENVI = FLTESCHE.EMENVI " _
            , " AND FLTMRES.PAFCOD = FLTESCHE.SCEPAI AND FLTFFINC.PAFCOD = FLTFENTI.PAFCOD AND FLTFFINC.ENFCOD = FLTFENTI.ENFCOD " _
            , " AND FLTMMAN.TDMCOD = FLTMTDES.TDMCOD " _
            , " rs.PAFCOD = '" & vPais & "' AND FLTEEMBA.SHECOD = '" & vBarco & "' AND FLTEEMBA.EMENVE = '" & vViaje & "' AND FLTEEMBA.ELICOD = '" & vLiner & "' ")
        .Refresh
    End With
Microsoft Excel

Avatar of undefined
Last Comment
cacha18cr

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jerry Miller

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Martin Liss

The same problem also exists in the line before that

FLTMMAN,DOLDATTRC.FLTPPROD FLTPPROD,DOLDATTRC.FLTEEMBA FLTEEMBA," _
            , " DOLDATTRC.FLTMCNT FLTMCNT, DOLDATTRC.FLTFORIG FLTFORIG,
Martin Liss

Wild guess here but the error message says that 'RS' is invalid and since the only place you have 'rs' is rs.PAFCOD, try changing that to FLTFENTI.PAFCOD or FLTFFINC.PAFCOD or whatever is appropriate.
cacha18cr

ASKER
Thank you, very much!
Your help has saved me hundreds of hours of internet surfing.
fblack61