检查访问表是否存在 [英] Check if access table exists

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

问题描述

我想记录网站访问的IP,日期时间,客户端和代理数据以访问数据库,但是我计划每天将日志数据记录在单独的表中,在06.06.2010的示例日志中将记录在2010_06_06命名表中.日期更改后,我将创建一个名为2010_06_07的表.但是问题是该表是否已经创建.

I want to log web site visits' IP, datetime, client and refferer data to access database but I'm planning to log every days log data in separate tables in example logs for 06.06.2010 will be logged in 2010_06_06 named table. When date is changed I'll create a table named 2010_06_07. But the problem is if this table is already created.

关于如何检查Access中是否存在表的任何建议?

Any suggestions how to check if table exists in Access?

推荐答案

您可以使用隐藏的系统表MSysObjects检查表是否存在:

You can use the hidden system table MSysObjects to check if a table exists:

If Not IsNull(DlookUp("Name","MSysObjects","Name='TableName'")) Then
    'Table Exists

但是,我同意每天创建一个新表是一个非常糟糕的主意.

However, I agree that it is a very bad idea to create a new table every day.

我应该补充一点,表的类型为1、4或6,不同类型的其他对象可能具有与表相同的名称,所以最好说:

I should add that tables have a type 1, 4 or 6 and it is possible for other objects of a different type to have the same name as a table, so it would be better to say:

If Not IsNull(DlookUp("Name","MSysObjects","Name='TableName' And Type In (1,4,6)")) Then
    'Table Exists

但是,无法创建与查询同名的表,因此,如果需要查找以测试名称,则最好将"5"(即查询)添加到类型"列表中

However, it is not possible to create a table with the same name as a query, so if you need a look up to test for a name, it may be best to add 5, that is query, to the Type list.

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

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