0
我可以在VBA Access 2010(VBA 7.0)的直接控制檯中運行選擇查詢的任何方式?如何從VBA控制檯查詢數據庫?
我可以在VBA Access 2010(VBA 7.0)的直接控制檯中運行選擇查詢的任何方式?如何從VBA控制檯查詢數據庫?
這爲我工作與返回整數查詢:
Public Sub runQuery(ByVal query As String)
Dim DB As DAO.Database: Set DB = CurrentDb()
Dim rst As DAO.Recordset: Set rst = DB.OpenRecordset(query)
Do While Not rst.EOF
Dim rowStr As String: rowStr = ""
Dim fld As Field
For Each fld In rst.Fields
rowStr = rowStr & fld & " "
Next fld
Debug.Print (rowStr)
rst.MoveNext
Loop
End Sub
然後從即時窗口調用它:
runQuery "SELECT Foo, Bar FROM MyTable WHERE Foo < 42"