Using a Command Object to query table
Sub CommandObject()
'Declare a Recordset and a Command object
Dim rst As ADODB.Recordset
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
cmd.CommandText = "Select * from Employees"
cmd.ActiveConnection = CurrentProject.Connection
Set rst = cmd.Execute
Debug.Print rst.GetString
rst.Close
Set cmd = Nothing
End Sub
Related examples in the same category