I have a function that deletes all ODBC linked tables ina BD. It work fine in an MDB, but when copied to an ACCDB it is failing wit the error message.
"Expected user-defined type, not project"
what is wronge? I have check both DB's and the referrences are the same.
Thanks
John Fuhrman
"Expected user-defined type, not project"
what is wronge? I have check both DB's and the referrences are the same.
Code:
Public Function DeleteODBCTableNames(Optional stLocalTableName As String)
On Error GoTo Err_DeleteODBCTableNames
Dim [highlight]dbs As Database[/highlight], tdf As TableDef, i As Integer
Set dbs = CurrentDb
If Len(stLocalTableName) = 0 Then
For i = dbs.TableDefs.Count - 1 To 0 Step -1
Set tdf = dbs.TableDefs(i)
If (tdf.Attributes And dbAttachedODBC) Then
dbs.TableDefs.Delete (tdf.Name)
End If
Next i
Else
dbs.TableDefs.Delete (stLocalTableName)
End If
DeleteODBCTableNames = True
dbs.Close
Set dbs = Nothing
Exit_DeleteODBCTableNames:
Exit Function
Err_DeleteODBCTableNames:
DeleteODBCTableNames = False
MsgBox ("Error # " & str(Err.Number) & " was generated by " & Err.Source & Chr(13) & Err.Description)
Resume Exit_DeleteODBCTableNames
End Function
Thanks
John Fuhrman