Ok the strIN looks ok, no comma in beginning. But I never find a match in the While loop.
If I look only for 1 part number I do not find it.
But if I search for the first record in the table I find it and get the 2 pieces of data, but the loop exceeds the (7000) limit yet I only have 3354 Records.
I'm at a loss. and yes this was a converted VB6 project.
I'm open to any and all suggestions.
Thanks
Code:Dim rs2 As New ADODB.Recordset 'A String variable into which you will build part of your 'WHERE clause using the SQL In Operator: Dim strIN As String Dim Test1(7000) As String Dim Test2(7000) As String Dim X As Integer strIN = "" For X = 1 To CBDrHDPLTCount strIN = strIN & ",'" & CBDrHDPLTPn(X) & "'" Next strIN = Replace(strIN, ",", "", 1, 1) X = 1 rs2.Open("SELECT Part_Number, Part_Desc " & _ "FROM tblMain " & _ "WHERE Part_Number In(" & strIN & ")", strConn2) While Not rs2.EOF If CBDrHDPLTPn(X) > "" And rs2.Fields("Part_Number").Value = CBDrHDPLTPn(X) Then Test1(X) = rs2.Fields("Part_Number").Value 'Part number from Database Test2(X) = rs2.Fields("Part_Desc").Value 'First of the items to pull from the data base End If X = X + 1 End While rs2.Close()




Reply With Quote