Private Sub FORM_LOAD()
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim prm As ADODB.Parameter
Dim cat As New ADOX.Catalog
Dim strDB As String
Dim i As Integer
' Append parameterized query
strDB = "MyTest.mdb"
If Dir(strDB) <> "" Then Kill (strDB)
cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDB
cmd.CommandText = "Select * From Table1 Where Fld1 = [CustId]"
Set prm = cmd.CreateParameter("CustId", adVarChar, adParamInput, 5)
cmd.Parameters.Append prm
' Append the new Procedure
cat.Procedures.Append "CustomerById", cmd
cat.Procedures.Refresh
cat.Views.Refresh
If cat.Procedures.Count = 0 Then
Debug.Print "No procedure in Procedures collection"
Else
For i = 0 To cat.Procedures.Count - 1
Debug.Print "Procedures Collection: " & cat.Procedures(i).Name
Next
End If
If cat.Views.Count = 0 Then
Debug.Print "No View in Views collection"
Else
For i = 0 To cat.Views.Count - 1
Debug.Print "Views Collection: " & cat.Views(i).Name
Next
End If
End Sub