Sub UnionX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")
    
    ' Retrieve the names and cities of all suppliers 
    ' and customers in Brazil.
    Set rst = dbs.OpenRecordset("SELECT CompanyName," _
        & " City FROM Suppliers" _
        & " WHERE Country = 'Brazil' UNION" _
        & " SELECT CompanyName, City FROM Customers" _
        & " WHERE Country = 'Brazil';")
    
    ' Populate the Recordset.
    rst.MoveLast
    
    ' Call EnumFields to print the contents of the 
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 12

    dbs.Close

End Sub

반응형

'VBA' 카테고리의 다른 글

k-means clustering in vba  (0) 2014.05.28
Access VBA  (0) 2013.04.28
VBA 날짜 함수 정리된 곳  (0) 2013.04.04
Excel VBA 이용해서 워드 파일 생성  (0) 2013.02.08
Application.OnTime 설명  (0) 2012.12.28

+ Recent posts