Link to home
Start Free TrialLog in
Avatar of keschuster
keschuster

asked on

MS Access VBA - returning a collection

I dug up a bit of code to handle relinking tables in MS Access.  Are part of it uses this function below to grab all of the linked table names.

when I run it I get an error I can't figure out.

Run-time error '450'
Wrong Number of Arguments or invalid property assignment.

Can anyone tell me why?


Function fGetLinkedTables() As Collection
'Returns all linked tables
    Dim collTables As New Collection
    Dim tdf As TableDef, db As Database
    Set db = CurrentDb
    db.TableDefs.Refresh
    For Each tdf In db.TableDefs
        With tdf
            If Len(.Connect) > 0 Then
                If Left$(.Connect, 4) = "ODBC" Then
                    collTables.Add Item:=.Name & ";" & .Connect, Key:=.Name
                'ODBC Reconnect handled separately
                Else
                    collTables.Add Item:=.Name & .Connect, Key:=.Name
                    'Debug.Print tdf.Name
                End If
            End If
        End With
    Next
    Set fGetLinkedTables = collTables
    Set collTables = Nothing
    Set tdf = Nothing
    Set db = Nothing
End Function

Open in new window

Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Interesting ... I do not get the error ...

mx
Avatar of keschuster
keschuster

ASKER

I've requested that this question be deleted for the following reason:

seems to have resolved itself
ASKER CERTIFIED SOLUTION
Avatar of BobOxford
BobOxford

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
keschuster
What fixed the problem ?
It worked as is for me.