在vba中获取本地表和链接表的名称 [英] Get the name of local table and linked table in vba

查看:96
本文介绍了在vba中获取本地表和链接表的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有五个表,其中两个是本地表,三个是链接表,我不确定我的代码如何获取表名.我想要一个代码,使用for循环分别为我提供两种类型的表名.

I have five tables in my application in which two are local table and three are linked table, I'm not sure about my code how to get name of table. I want a code for provide me name of both type of table name separately using for loop.

表名

LocalTable1
LocalTable2
LinkTable1
LinkTable2
LinkTable3

代码

Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
  Debug.Print td.Name 
Next

推荐答案

您可以使用源表名称:

Dim db As Database
Dim tdf As TableDef

Set db = CurrentDb

For Each tdf In db.TableDefs
    If Left(tdf.Name, 4) <> "MSys" Then
        Debug.Print tdf.Name & IIf(tdf.SourceTableName <> "", "  source table: " _
            & tdf.SourceTableName, "")
    End If
Next

这篇关于在vba中获取本地表和链接表的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆