Results 1 to 4 of 4

Thread: [RESOLVED] Collection Problem.

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Resolved [RESOLVED] Collection Problem.

    vb Code:
    1. Private Sub Form_Load()
    2. Dim rs As ADODB.Recordset, rs_1 As ADODB.Recordset
    3. Dim pstrFIELD As String, pstrTABLE As String, pstrWHERE As String, pstrGROUP As String
    4. Dim pstrWHEREAll As String
    5. Dim Loc As String
    6. Dim DeptCollection As Collection
    7. Dim iCol As String, i As Integer
    8. Dim strDept As String
    9. Me.lvwShowDetail.Visible = True
    10. Loc = Me.lvwShowBlock.SelectedItem.Text
    11. pstrFIELD = " Loc,Count(Mac_Code) as CountMac," & _
    12.             " (SELECT Count(Mac_Code) as CountMac" & _
    13.             " From dbo.Machine_Desc" & _
    14.             " WHERE (Status = 'Absolute Critical') AND Loc = '" & Loc & "' AND Condition = 'BreakDown'" & _
    15.             " GROUP BY Loc) as CountAC," & _
    16.             " (SELECT Count(Mac_Code) as CountMac" & _
    17.             " From dbo.Machine_Desc" & _
    18.             " WHERE (Status = 'Between Critical') AND Loc = '" & Loc & "' AND Condition = 'BreakDown'" & _
    19.             " GROUP BY Loc) as CountBC," & _
    20.             " (SELECT Count(Mac_Code) as CountMac" & _
    21.             " From dbo.Machine_Desc" & _
    22.             " WHERE (Status = 'Common Critical') AND Loc = '" & Loc & "' AND Condition = 'BreakDown'" & _
    23.             " GROUP BY Loc) as CountCC"
    24. pstrTABLE = "dbo.Machine_Desc"
    25. pstrGROUP = " GROUP BY Loc"
    26. pstrWHEREAll = " WHERE Status IN('Absolute Critical','Between Critical','Common Critical') AND Loc = '" & Loc & "' AND Condition = 'Breakdown'"
    27.     Set rs_1 = SQLSELECT("Dept", pstrTABLE, pstrWHEREAll, " GROUP BY Dept", "", "Maintenance")
    28.         Set DeptCollection = New Collection
    29.             Do While Not rs_1.EOF
    30.                  iCol = Val(iCol) + 1
    31.  
    32.                 DeptCollection.Add IIf(IsNull(rs_1.Fields(0)), " ", rs_1.Fields(0)), iCol
    33.                
    34.                 rs_1.MoveNext
    35.             Loop
    36.             On Error GoTo err:
    37.             For i = 1 To DeptCollection.Count
    38.             '***************** PRoblem is here *************************
    39.                 strDept = strDept & " " & DeptCollection.Item(i) 'Problem exist here
    40.             '***************** PRoblem  *************************
    41.             Next
    42.             strDept = Replace(Trim(strDept), " ", ",")
    43.     Set rs = SQLSELECT(pstrFIELD, pstrTABLE, pstrWHEREAll, pstrGROUP, "", "Maintenance")
    44.    
    45.     Call LoadItmxPreSumOfLoc(rs, strDept)
    46.    
    47. err:
    48.     MsgBox err.Number
    49. End Sub

    I was facing a problem at the line of code i highlighted, when i debugging until the highlighted code the err.number show me 9. Furthermore, if i do not used error handle. The Project will close directly.

    I'm not similar to use collection. Thus, the problem may happened in collection.

    Thanks in millions for helps.
    Last edited by nUflAvOrS; Nov 27th, 2007 at 06:41 AM.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

Posting Permissions

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



Click Here to Expand Forum to Full Width