I have multiple tables, within some of those tables I have fields that are formatted as hyperlink. I want to return the tables names that contain hyperlink formatted fields and the subsequent field names?
I am trying to do this within VBA, I'm thinking an SQL call within VBA.
You can loop through every tableDef
/Table in the database, but it gets a little hairy since hyperlinks are an attribute on a memo
field type. The Attributes
property of Access objects are a bitmask, so when checking to see if a particular attribute is set, you have to check if that attributes bit is set in the bitmask.
Sub ListTablesWithHyperlinks()
Dim tdf As TableDef
Dim fld As Field
Dim tdfPrint As Boolean
'Loop through all tables
For Each tdf In CurrentDb.TableDefs
'Set flag to false
tdfPrint = False
'Loop through all fields
For Each fld In tdf.Fields
'Test if column has an attribute of `dbHyperlinkField`
If (fld.Attributes And dbHyperlinkField) = dbHyperlinkField Then
'Set the flag and exit the loop
tdfPrint = True: Exit For
End If
Next fld
'If the flag was set to true, then iterate fields again and print out
If tdfPrint Then
For Each fld In tdf.Fields
'Print out tablename, column ordinal, and column name
Debug.Print tdf.Name, fld.OrdinalPosition, fld.Name
Next fld
End If
Next tdf
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.