Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2013
    Posts
    2

    Unanswered: Run-time error 3265 "ITEM NOt Foun in this collection"

    ' Can somebody help me,please?

    Private Sub newTARV14()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim rs1 As DAO.Recordset
    Dim rs4 As DAO.Recordset

    Dim sql As String
    Dim str As String
    Dim sql4 As String

    Set db = CurrentDb

    db.Execute "delete * from t_tarv14"

    sql4 = "select * from t_tarv14"
    Set rs4 = db.OpenRecordset(sql4)
    'TARV12
    str = " SELECT caminho, Sum(IIf(idade<15,1,0)) AS Individual_0_14_12, Sum(IIf(idade>=15,1,0)) AS Individual_maior_15_12"
    str = str & " FROM ( SELECT t_estadiamentoAntesDeTarv.caminho, t_estadiamentoAntesDeTarv.nid, t_estadiamentoAntesDeTarv.sexo, t_estadiamentoAntesDeTarv.idade FROM t_estadiamentoAntesDeTarv INNER JOIN t_estadiamentoDepoisDeTarv ON t_estadiamentoAntesDeTarv.nid = t_estadiamentoDepoisDeTarv.nid WHERE (((t_estadiamentoAntesDeTarv.estadiooms)<>[t_estadiamentoDepoisDeTarv].[estadiooms])) GROUP BY t_estadiamentoAntesDeTarv.nid, t_estadiamentoAntesDeTarv.sexo, t_estadiamentoAntesDeTarv.idade, t_estadiamentoAntesDeTarv.caminho)"
    str = str & " GROUP BY caminho"

    'TARV13
    str = str & " UNION "
    str = " SELECT t_cd4AntesDeTARV.caminho, SUM(IIF( i<15 and falencia >0,1,0)) as Individual_0_14,"
    str = str & " SUM(IIF( i>=15 and falencia >0,1,0)) as Individual_maior_15"
    str = str & " FROM"
    str = str & " ("
    str = str & " SELECT t_cd4AntesDeTARV.caminho, t_cd4AntesDeTARV.nid, t_cd4AntesDeTARV.sexo, t_cd4AntesDeTARV.idade AS i, t_CD4DepoisTARV.minimoCD4, t_CD4DepoisTARV.minimoCD4/2 as metadeCD4Inicial, t_cd4AntesDeTARV.maximoCD4,"
    str = str & " IIF(t_cd4AntesDeTARV.maximoCD4/2 >= t_CD4DepoisTARV.minimoCD4 OR (t_CD4DepoisTARV.minimoCD4 <100 AND t_cd4AntesDeTARV.maximoCD4 <100 AND ((DateDiff('m',t_cd4AntesDeTARV.datainiciotarv,dat aUltimoCD4))>12) ) ,1,0) AS falencia"
    str = str & " FROM t_cd4AntesDeTARV INNER JOIN t_CD4DepoisTARV ON t_cd4AntesDeTARV.nid = t_CD4DepoisTARV.nid"
    str = str & " WHERE (((t_cd4AntesDeTARV.idade) >= 5))"
    str = str & ") group by t_cd4AntesDeTARV.caminho "



    'Debug.Print str

    Set rs1 = db.OpenRecordset(str)

    If Not rs1.BOF Then
    rs1.MoveFirst
    End If

    While Not rs1.EOF
    rs4.AddNew

    rs4!caminho = rs1!caminho

    If Not IsNull(rs1!Individual_0_14_12) Then
    rs4!clinical_failure_Age_0_14 = rs1!Individual_0_14_12
    End If

    If Not IsNull(rs1!Individual_maior_15_12) Then
    rs4!clinical_failure_Age_15_mais = rs1!Individual_maior_15_12
    End If

    If Not IsNull(rs1!Individual_0_14_13) Then
    rs4!immunologic_failure_Age_0_14 = rs1!Individual_0_14_13
    End If

    If Not IsNull(rs1!Individual_maior_15_13) Then
    rs4!immunologic_failure_Age_15_mais = rs1!Individual_maior_15_13
    End If

    rs4.Update

    rs1.MoveNext
    Wend

    rs1.Close

    rs4.Close

    db.Close


    MsgBox ("Completou newTarv14")

    End Sub

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    And the question is ?
    Have a nice day!

  3. #3
    Join Date
    Apr 2013
    Posts
    2
    Hi Sinndho

    When try to run this query it pops up :Run-time error 3265 "ITEM NOt Foun in this collection" in followinf part of the code:

    If Not IsNull(rs1!Individual_0_14_13) Then
    rs4!immunologic_failure_Age_0_14 = rs1!Individual_0_14_13
    End If

    If Not IsNull(rs1!Individual_maior_15_13) Then
    rs4!immunologic_failure_Age_15_mais = rs1!Individual_maior_15_13
    End If

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so in your opinion which of those two columns is not defined in the recordset?
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    In your query, you define the aliases: Individual_0_14_12, Individual_maior_15_12, Individual_0_14 and Individual_maior_15, but not: Individual_0_14_13 and Individual_maior_15_13.

    Moreover, I don't know which are the columns of t_tarv14 that are used to open rs4. You should check there too for immunologic_failure_Age_0_14 and immunologic_failure_Age_15_mais
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •