Hi
Below is the code I use to return some values from an Informix database. The query should return 13 values, but only actually returns 12 of them. 2 of the 13 values are the same though. eg bannana, egg, egg, orange, apple, grape etc.
For some reason the recordset call is removing any replcates. How do I stop this from happening and return all 13 records.
--------------------------------------------------
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim fld As ADODB.Field
Dim SQL1 As String
Dim SQL2 As String
Dim SQLFINAL As String
Sub Button1_Click()
cn.ConnectionString = "metrix"
cn.Provider = "msdatashape"
cn.CursorLocation = adUseNone
cn.Open
SQL1 = "Select sample.job_no from sample where sample.user_decimal_1 in (" & "9662" & ""
SQL2 = "Select qa_sample.job_no from qa_sample where qa_sample.user_decimal_1 in (" & "9662" & ""
SQLFINAL = SQL1 & " union " & SQL2
rs.Open SQLFINAL, cn, adOpenForwardOnly, adLockReadOnly
rs.Sort = "job_no Asc"
While Not rs.EOF
For Each fld In rs.Fields
Range("B1".Value = rs.RecordCount
Num_Str = "(A" & Pos1_Num & ""
Range(Num_Str).Value = fld.Value
rs.MoveNext
Pos1_Num = Pos1_Num + 1
Next
Wend
cn.Close
end sub
Below is the code I use to return some values from an Informix database. The query should return 13 values, but only actually returns 12 of them. 2 of the 13 values are the same though. eg bannana, egg, egg, orange, apple, grape etc.
For some reason the recordset call is removing any replcates. How do I stop this from happening and return all 13 records.
--------------------------------------------------
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim fld As ADODB.Field
Dim SQL1 As String
Dim SQL2 As String
Dim SQLFINAL As String
Sub Button1_Click()
cn.ConnectionString = "metrix"
cn.Provider = "msdatashape"
cn.CursorLocation = adUseNone
cn.Open
SQL1 = "Select sample.job_no from sample where sample.user_decimal_1 in (" & "9662" & ""
SQL2 = "Select qa_sample.job_no from qa_sample where qa_sample.user_decimal_1 in (" & "9662" & ""
SQLFINAL = SQL1 & " union " & SQL2
rs.Open SQLFINAL, cn, adOpenForwardOnly, adLockReadOnly
rs.Sort = "job_no Asc"
While Not rs.EOF
For Each fld In rs.Fields
Range("B1".Value = rs.RecordCount
Num_Str = "(A" & Pos1_Num & ""
Range(Num_Str).Value = fld.Value
rs.MoveNext
Pos1_Num = Pos1_Num + 1
Next
Wend
cn.Close
end sub