Breaking News

Tuesday, June 26, 2012

Ex13: VBA - Create a query using ADOX


Function CreateViewAdox()
'Purpose: Create a query using ADOX.
Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
Dim strSql As String

'Initialize.
cat.ActiveConnection = CurrentProject.Connection

'Assign the SQL statement to Command object's CommandText property.
strSql = "SELECT BookingID, BookingDate FROM tblDaoBooking;"
cmd.CommandText = strSql

'Append the Command to the Views collectiion of the catalog.
cat.Views.Append "qryAdoxBooking", cmd

'Clean up.
Set cmd = Nothing
Set cat = Nothing
Debug.Print "View created."
End Function

No comments:

Post a Comment

Designed By Published.. Blogger Templates