VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Returns a list of all tables that contain a field with the given name

by VB-Kung-Fu (19 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 9th December 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Returns a list of all tables that contain a field with the given name

Rate Returns a list of all tables that contain a field with the given name




'*******************************************************
'FindFieldInTables
'   Searches through the database and returns
'   a list of all the tables containing
'   the named field. The list is delimited
'   using the specified delimeter.
'*******************************************************
Public Function FindFieldInTables(FldName As String, Optional Delimeter As String = vbCrLf) As String
Dim tdf As TableDef, fld As Field, res As String

If FldName = "" Then Exit Function Else FldName = Trim(FldName)

For Each tdf In CurrentDb.TableDefs
    For Each fld In tdf.Fields
        If StrComp(fld.Name, FldName, vbTextCompare) = 0 Then
            res = res & tdf.Name & Delimeter
        End If
    Next
Next

'strip off trailing delimeter when returning result
If Len(res) > 1 Then
    FindFieldInTables = Left(res, Len(res) - Len(Delimeter))
End If
End Function

Download this snippet    Add to My Saved Code

Returns a list of all tables that contain a field with the given name Comments

No comments have been posted about Returns a list of all tables that contain a field with the given name. Why not be the first to post a comment about Returns a list of all tables that contain a field with the given name.

Post your comment

Subject:
Message:
0/1000 characters