Sub CreateQuery()
Dim cmd As ADODB.Command
Dim strSQL As String
Dim cat As ADOX.Catalog
Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
Set cmd = New ADODB.Command
cmd.CommandText = "Select * From Employees Where State='CA'"
cat.Views.Append "qryCAClients", cmd
cat.Views.Refresh
Set cat = Nothing
Set cmd = Nothing
End Sub
|