Using a Command Object to query table : ADODB Command « Access « VBA / Excel / Access / Word






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

1.Command.Execute method
2.Use ADODB.Command to create a view