Sub Execute_SelectQuery()
Dim cmd As ADODB.Command
Dim myRecordset As ADODB.Recordset
Dim strPath As String
strPath = CurrentProject.Path & "\mydb.mdb"
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath
.CommandText = "[Products by Category]"
.CommandType = adCmdTable
End With
Set myRecordset = New ADODB.Recordset
Set myRecordset = cmd.Execute
Debug.Print myRecordset.GetString
myRecordset.Close
Set myRecordset = Nothing
Set cmd = Nothing
End Sub
|