简体   繁体   English

VBA问题:debug.print显示正确的数据-如何从即时窗口中获取数据?

[英]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.

相关问题 有没有办法在使用 debug.print 时让直接窗口显示实际选项卡而不是 4 个空格 - Is there a way to make immediate window show actual tabs instead of 4 spaces when using debug.print 如何在VBA / Access中从查询设计中调试查询结果 - How to debug.print a query result from the query design in VBA /Access 如何在 Access 中将 Debug.print 打印到列或文本字段中? - How to Debug.print into a column or text field in Access? 当记录存在时,MS Access VBA .recordcount返回0,而debug.print返回值 - MS Access VBA .recordcount returning 0 when records exist, and debug.print returns value 在即时窗口中查看记录集的数据 - view data of recordset in immediate window 使用 VBA,如何从路径字符串中获取直接父文件夹名称? - Using VBA, how can I get the immediate parent folder name from a path string? VBA-使用标准而不是立即打印通过Printout打印Word文档 - VBA - Use standard instead of immediate printing to print word doc with Printout 将计算字段表达式的值打印到 Microsoft Access 即时窗口 - Print Calculated Field Expression's Value to the Microsoft Access Immediate Window MS Access VBA创建即时窗口弹出窗口或模拟一个窗口 - MS Access VBA Create a immediate window popup or simulate one 如何确保MS Access显示当前记录的正确子报告数据? - How to make sure that MS Access displays the correct subreport data of the current record?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM