Hi
I want to execute two sql queries in the below program
Sub Unique_MFGID_Unmatched()
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & InputBox("Please Enter File Path & File name With extension", "Enter FileName", "c:\test.mdb") & ";Persist Security Info=False"
con.Open
rs.Open "SELECT tblMatchedtb.ITEM, tblMatchedtb.Desc, tblMatchedtb.MFG, tblMatchedtb.MFGID, tblMatchedtb.PACK, tblMatchedtb.UOM, tblMatchedtb.COST, tblMatchedtb.mhs_count, tblMatchedtb.Building, tblMatchedtb.DEPART, tblMatchedtb.Area, tblMatchedtb.SOURCEID FROM tblMatchedtb WHERE (((tblMatchedtb.COST) = 0)) and re_processed= 0 ORDER BY tblMatchedtb.MFGID", con, adOpenForwardOnly, adLockReadOnly
Workbooks.Add
Cells.NumberFormat = "@"
For i = 0 To rs.Fields.Count - 1
Cells(1, i + 1) = rs(i).Name
Next
j = 2
Do Until rs.EOF
If IsNull(rs(3)) Or rs(3) = "" Then
k = 13
n = 1
For i = 0 To rs.Fields.Count - 1
Cells(j, i + 1) = rs(i).Value
Next
j = j + 1
Else
If sPrevious <> rs(3) Then
k = 13
For i = 0 To rs.Fields.Count - 1
Cells(j, i + 1) = rs(i).Value
Next
n = 1
j = j + 1
ElseIf sPrevious = rs(3) Then
Cells(1, k) = "SOURCEID" & n
If Cells(j - 1, 9) <> rs(11) Then
Cells(j - 1, k) = rs(11)
End If
k = k + 1
Cells(1, k) = "DEPT" & n
Cells(j - 1, k) = rs(9)
k = k + 1
Cells(1, k) = "AREA" & n
Cells(j - 1, k) = rs(10)
k = k + 1
n = n + 1
End If
End If
If Not IsNull(rs(3)) Then
sPrevious = rs(3)
End If
rs.MoveNext
Loop
End Sub
I WANT EXECUTE ONE MORE SQL STATEMENT THE RESULT SHOULD BE IN THE SAME SHEET ITSELF
Bookmarks