【问题标题】:VBA to search the external data table for a recordVBA 在外部数据表中搜索记录
【发布时间】:2015-12-11 21:17:56
【问题描述】:

我已链接到 Visio 2013 中的外部数据,并且有四个不同的选项卡/表格。当用户双击一个形状时,该形状的文本将用于在表格中搜索记录。请注意,此数据未在 Visio 链接数据方法中链接。只需要手动搜索表格,而不依赖于数据记录和预先存在的形状之间的某些链接。 外部数据导入正常。我可以捕获双击形状的文本。如果您能告诉我如何针对已拉入 Visio 的外部数据运行查询,则突出显示该行。 谢谢你

【问题讨论】:

  • 请提供更多技术信息,如屏幕、代码、数据等...
  • 您是如何将这些外部数据导入 visio的?

标签: vba visio


【解决方案1】:

一旦您获得了有关数据源的信息(例如服务器/数据库名称、凭据等),您只需在模块中添加几行 VBA,如下所示:

Dim theVariableForDataFieldYouWant as Integer
Dim db as database
Dim rs as recordset
Set db = YourDataConnectionStringHere
Dim sql as string
sql = "Select aFieldYouWant, anotherFieldYouWant from yourTableName WHERE someField = yourCriteria"
set rs = db.openRecordSet(sql)

if rs.eof then
' you recordset is empty, nothing matched
else
theVariableForDataFieldYouWant = rs.fields("theDataField")
end if

rs.close
db.close
set rs = nothing
set db = nothing

如果您提供更多细节,我可以更准确,但基本上就是这样总结。将代码放入函数或子函数中,然后在您选择的事件上调用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-13
    • 1970-01-01
    相关资源
    最近更新 更多