打开记录集时出错 [英] Error opening a recordset

查看:59
本文介绍了打开记录集时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是查看是否可以打开链接到另一个Access数据库的表,以便我可以进行测试以确保连接确实存在,并且不需要重新连接到其他BE或其他位置。有人建议首先检查文件是否存在于我认为应该存在的位置,然后查看是否可以打开记录集。如果两者都回来了,那我很好。否则,如果一个人回来假,那么我需要重新连接到BE。我有代码来测试文件是否存在,我现在只需要弄清楚如何查看是否可以打开记录集。


嗯,我打开记录集和陷阱错误并没有太好用。我尝试复制MSDN的这里,但由于某种原因,我在第8行得到运行时错误3219:无效操作。这就是我所拥有的:

展开 | 选择 | Wrap | 行号

解决方案

没关系,我刚修好它。

展开 | 选择 | Wrap | 行号


我仍然想知道为什么参数被命名为 strDBName OpenRecordset()不处理数据库。如果你正在处理一个表,那么 dbOpenTable 不应该导致任何问题。如果是,那么你还有其他错误需要注意。


在这种情况下,我们需要知道 strDBName 的确切值,如果我们'要确定删除 dbOpenTable 隐藏的代码仍然存在问题。此外,这个值是您希望有效的表的名称吗?


我不能说我在想它命名为strDBName。可能是因为与Exist功能合作太多了。我将它重命名为strTblName,以便更有意义。


目前strDBName解析为tblTest(如代码块下面的第一篇文章所述),它是我试图测试的链接表的名称。

My goal is to see if I can open a table that is linked to another Access database so that I can test to make sure that the connection does exist and doesn''t need reconnected to a different BE or just another location. It was suggested to first check if the file existed where I thought it should be and then see if I can open the recordset. If both come back true, then I''m good. Otherwise if one comes back false, then I need to reconnect to the BE. I have the code to test if the file exists and I now just need to figure out how to see if I can open the recordset.

Well, my stab at opening the recordset and trapping the error didn''t work too well. I tried copying what MSDN had here, but I''m getting a Run-time error 3219: Invalid Operation on line 8 for some reason. Here is what I have:

Expand|Select|Wrap|Line Numbers

解决方案

Never mind, I just fixed it.

Expand|Select|Wrap|Line Numbers


I still want to know why the parameter is named strDBName? OpenRecordset() doesn''t deal with databases. If you''re dealing with a table then dbOpenTable shouldn''t be causing any issues. If it is, then you have something else wrong that needs looking at.

In the circumstances, we need to know the exact value of strDBName if we''re to determine what is still wrong with the code that removing dbOpenTable hides away. Also, is this value the name of a table you expect to be valid or not?


I can''t say what I was thinking naming it strDBName. Probably because of working with the Exist function so much. I will rename it strTblName so that it makes more sense.

Currently strDBName resolves to tblTest (as stated in the first post below the code block) and it is the name of the linked table that I''m trying to test.


这篇关于打开记录集时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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