检查记录是否存在打开表格 [英] Check for Existence of Record THEN Open Form

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

问题描述

大家好,再次感谢您花时间帮助解决我的问题!


这个问题在我看来似乎非常简单,但是让编码让它工作是确定不是那么简单...


基本上我要做的是检查命令按钮以查看当前的记录ID是否正确。存在于姐妹表中,然后在用户点击它时打开姐妹表的绑定表单进行编辑。


我想我可以通过SELECT查询来搜索当前记录的记录ID。在姐妹表中,并将其与If Then相结合。声明将 a)允许访问表单或 b)如果SELECT查询的结果为空或空并且禁止访问,则弹出一个MsgBox。


从我的研究中,下面的代码应该可以工作,但Access一直挂在Dim db As Database上。线,我不能为我的生活搞清楚!

Hello guys, thanks again for taking the time to help me out with my problems!

This problem seems super simple in my head, however getting the coding to make it work is turing out to be not so simple...

Basically what I am trying to do is have a Command Button check to see whether the current "Record ID" exists in the sister table before opening the sister table''s bound form for editing when the user clicks on it.

I figured that I would be able to do this with a SELECT query that does a search for the current record''s "Record ID" in the sister table, and couple it with an "If Then" statement that will either a) allow access to the form or b) pop up a MsgBox if the results of the SELECT query are Null or Empty and disallow access.

From my research the code below should work, but Access keeps getting hung up on the "Dim db As Database" line, and I cannot for the life of me figure it out!


展开 | 选择 | Wrap | 行号

推荐答案

检查您是否有对Microsoft DAO对象库的引用。同样,在声明数据对象时,您应该使用对DAO或ADO对象库的完整引用。

Check that you have a reference to Microsoft DAO Object Library. Also when declaring data objects you should use the full reference to a DAO or ADO object library.

展开 | 选择 | Wrap | 行号



检查您是否有对Microsoft DAO对象库的引用。同样,在声明数据对象时,您应该使用对DAO或ADO对象库的完整引用。

Check that you have a reference to Microsoft DAO Object Library. Also when declaring data objects you should use the full reference to a DAO or ADO object library.

展开 | 选择 | Wrap | 行号


对不起,我在上一篇文章中应该更清楚地检查你的参考资料。


你需要去工具>从VBA编辑器窗口引用并确保您已包含Microsoft DAO对象库。
Sorry I should have been more clear in my previous post about checking your reference.

You need to go to Tools > References from the VBA editor window and ensure that you have included the Microsoft DAO Object Library.


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

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