[AccessD] Itterate a collection

S D accessd667 at yahoo.com
Fri Oct 22 01:16:34 CDT 2004


Hi group,
 
I've got a class that returns a collection....how the $#$ call I iterate that collection?
 
TIA
 
SD
 
Here's the code I use in my form:
Private Sub cmdRetrieveTablenames_Click()
   Dim cDO As cDatabaseObjects
   Dim oColl As Collection
   
   Set cDO = New cDatabaseObjects
   Set oColl = New Collection
   
   cDO.TableNames
   
End Sub
 
Here's the code in the class cDatabaseObjects:
Public Function TableNames() As Collection
   On Error GoTo errHandler
   
   Dim oCatalog As New ADOX.Catalog
   Dim oTableNames As New Collection
   Dim oTables As ADOX.Tables
   Dim oTable As ADOX.Table
   Dim oConnection As New ADODB.Connection
 
   Set oCatalog.ActiveConnection = CurrentProject.Connection
   Set oTables = oCatalog.Tables
 
   For Each oTable In oTables
      oTableNames.Add oTable.Name
   Next
   Set TableNames = oTableNames
errHandler:
   On Error Resume Next
   If oConnection.State <> 0 Then oConnection.Close
   Set oConnection = Nothing
   Set oCatalog = Nothing
   Set oTable = Nothing
   Set oTables = Nothing
End Function

 
 

		
---------------------------------
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.


More information about the AccessD mailing list