In my database I have certain tables that have confidential information. Each of these tables contains an empty field called "ThisTableIsConfidential". I have a function that correctly displays a list of the tables that have this field in the Immediate window. Now I want to display the list on a form and I can't figure out how to do it. I thought to put the function in a query and display that in a listbox but the query didn't work. Any ideas?
This is the function (I cobbled it together from a few different online sources):
Function GetConfidentialTable()
Dim db As Database, tbl As TableDef, fld As Field, currentTable As String
Set db = CurrentDb
For Each tbl In db.TableDefs
If (tbl.Attributes = 0) Then
currentTable = tbl.Name
If FieldExists(currentTable, "ThisTableIsConfidential") = True Then
Debug.Print currentTable
End If
End If
Next tbl
End Function