[英]VBA question: debug.print displays the correct data - how to get it out of Immediate window?
In my database I have certain tables that have confidential information. 在我的数据库中,有些表包含机密信息。 Each of these tables contains an empty field called "ThisTableIsConfidential". 这些表中的每个表都包含一个名为“ 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
You can set the listbox row source type to Value List and then use your function to return a list: 您可以将列表框行源类型设置为“值列表”,然后使用函数返回列表:
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
sList = sList & ";" & currentTable
End If
End If
Next tbl
GetConfidentialTable = Mid(sList,2)
End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.