如何检查MS Access for vb宏中是否存在表 [英] How to check if a table exists in MS Access for vb macros

查看:97
本文介绍了如何检查MS Access for vb宏中是否存在表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
检查访问表是否存在

Possible Duplicate:
Check if access table exists

我是vba宏的新手.任何想法如何检查表是否存在? 我已经搜索过以前的帖子,但是对此没有明确的解决方案.

I'm new to vba macros. Any idea how to check if a table exists or not? I have searched for previous posts but did not get a clear solution for this.

推荐答案

设置对Microsoft Access 12.0对象库的引用可以使我们使用DCount测试表是否存在.

Setting a reference to the Microsoft Access 12.0 Object Library allows us to test if a table exists using DCount.

Public Function ifTableExists(tblName As String) As Boolean

    If DCount("[Name]", "MSysObjects", "[Name] = '" & tblName & "'") = 1 Then

        ifTableExists = True

    End If

End Function

这篇关于如何检查MS Access for vb宏中是否存在表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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