<<< 返回 access911.net 编程静态资料库索引页 如何判定一个表是否存在? 作者:cg1 摘自:access911.net 录入:cg1 时间:2003-8-8 浏览人次:2604
专题地址:http://www.access911.net/index.asp?u1=a&u2=77FABE1E1ADC 如果需要更详细的评论或说明,请点击该地址。 简述:如何判定一个表是否存在?《VBA》 问题:
方法一:
| 很多人问如何判定一个表是否存在于某个数据库,有人会回答,用msysobjects这个表来判定啊,这是个Access高级技巧。但是默认情况下admin对系统表没有读取权限,你需要手动设定,这该怎么办哪?要么你去设定一下权限(相关方法在本站另有动画以及文章介绍,这里不再阐述) 现在说两种方法来解决判定问题 以下这种方法就是使用陷阱,造成一个错误,通过系统错误来判定某个表是否存在 这是个少有人介绍,但是很实用的技巧。 Function test() MsgBox TableIsIn("表2") End Function Function TableIsIn(TableName As String) TableIsIn = True On Error Resume Next Dim strSQL As String strSQL = "select * from " & TableName CurrentDb.Execute strSQL If Err.N..................... ........... |
|
|