Monday, 25 June 2012

Ex3: VBA - Create a new query using ADO

Create a new query using ADO in VBA

Function CreateViewAdo()
    'Purpose:   Create a new query using ADO.
    Dim cn As ADODB.Connection
    Dim strSql As String
    
    strSql = "CREATE VIEW MyTableView AS SELECT MyTable.* FROM MyTable;"
    Set cn = CurrentProject.Connection
    cn.Execute strSql
    
    Debug.Print "MyTableView created"
    Set cn = Nothing
End Function

No comments:

Post a Comment