适用于:Access 2013、Office 2013
下面的代码演示如何刷新 Catalog 的 Views 集合。 必须先执行此操作,然后才能访问 Catalog 中的 View 对象。
' BeginViewsRefreshVB
Sub Main()
On Error GoTo ProcedureViewsRefreshError
Dim cat As New ADOX.Catalog
' Open the Catalog
cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
"Data Source='c:\Program Files\" & _
"Microsoft Office\Office\Samples\Northwind.mdb';"
' Refresh the Procedures collection
cat.Views.Refresh
'Clean up
Set cat = Nothing
Exit Sub
ProcedureViewsRefreshError:
If Not cat Is Nothing Then
Set cat = Nothing
End If
If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
' EndViewsRefreshVB