运行时错误2001您取消了上一个操作 [英] Run-time Error 2001 you canceled the previous operation
问题描述
我一直试图解决这个问题几个星期,在阅读论坛中有关该主题的每篇文章后,我都没有发现任何可行的内容。
我有两张桌子;
1)有公司编号/成本中心,等级,市场和地区
2)主表到信息的来源。
我知道它与成本中心有关,因为我调试时,其他一切都有效。
我的代码如下:
I have been trying to figure this out for a couple weeks and after reading every post in the forum about the subject I have not found anything that works.
I have two tables;
1) has company numbers/cost centers, hierarchys, markets, and regions
2) the main table to which the information goes to.
I know it has something to do with the cost centers beacuse when I debug, everything else works.
My code is as follows;
推荐答案
我认为co_cost_ctr是字母数字而不仅仅是数字
另外,如果没有找到记录,DLOOKUP将返回null。您正在设置的3个字段的类型是什么?你可以用新西兰包装DLOOKUP并提供默认值
例如
Me.Region = NZ(DLookup(Region,[CostCtr /] Hierarchy],[Co_Cost_Ctr] =''"& Me。[Co_Cost_Center]&"''"),"
还有一件事要尝试,你的数据库并没有腐败。我在腐败的数据库导致该错误之前听说过。很少但已经发生了,所以你可以试试一个小型/维修或反编译(总是首先备份db,如果没有区别则坚持使用原始版本)
I take it the co_cost_ctr is alphanumeric and not just numeric
Another thing, DLOOKUP returns null if no records found. What are the types for the 3 fields you are setting? U could wrap DLOOKUP with NZ and supply a default value
eg
Me.Region = NZ(DLookup("Region", "[CostCtr/Hierarchy]", "[Co_Cost_Ctr] = ''" & Me.[Co_Cost_Center] & "''"),"")
One more thing to try, your DB is not corrupt right. Ive heard before a corrupt db causing that error. Rare but has happened, so u could try a compact/repair or a decompile (always backup db first, stick with original if it makes no difference)
我认为co_cost_ctr是字母数字和不只是数字
另外,如果没有找到记录,DLOOKUP将返回null。您正在设置的3个字段的类型是什么?你可以用新西兰包装DLOOKUP并提供默认值
例如
Me.Region = NZ(DLookup(Region,[CostCtr /] Hierarchy],[Co_Cost_Ctr] =''"& Me。[Co_Cost_Center]&"''"),"
还有一件事要尝试,你的数据库并没有腐败。我在腐败的数据库导致该错误之前听说过。很少但已经发生了,所以你可以试试一个小型/维修或反编译(始终首先备份数据库,如果没有区别则坚持原始数据)
I take it the co_cost_ctr is alphanumeric and not just numeric
Another thing, DLOOKUP returns null if no records found. What are the types for the 3 fields you are setting? U could wrap DLOOKUP with NZ and supply a default value
eg
Me.Region = NZ(DLookup("Region", "[CostCtr/Hierarchy]", "[Co_Cost_Ctr] = ''" & Me.[Co_Cost_Center] & "''"),"")
One more thing to try, your DB is not corrupt right. Ive heard before a corrupt db causing that error. Rare but has happened, so u could try a compact/repair or a decompile (always backup db first, stick with original if it makes no difference)
共同/成本中心是字母数字。我不确定我理解你所设定的三个领域的类型。如果这就是你的意思,它们都是文本字段。
我试图压缩/修复数据库而它什么也没做。
我会尝试新西兰的东西,但我不知道那会做什么。
我知道它与Co / cost ctr有关,因为这是卡住的地方。我是相当新的Access,所以我道歉不理解你说的一些事情。
The co/cost center is alphanumeric. Im not sure I understand what you ean by the types for the three fields I am setting. They are all text fields if that is what you mean.
I tried compacting/repairing the database and it did nothing.
I will try the NZ thing but Im not sure what that will do.
I know it has something to do with the Co/cost ctr because that is where it gets stuck. Im fairly new with Access so I appologize for not understanding some of the things you are saying.
没问题
现在你执行DLOOKUP ,它是一次获取,如果你使用相同的标准做多个DLOOKUPS,它的速度很慢(虽然你可能没注意到)所以最好使用一个记录集
例如
No problems
Now when u perform a DLOOKUP, it is one fetch, if you are doing multiple DLOOKUPS using the same criteria, its slow (though u may not notice) so its better to use a recordset
eg
这篇关于运行时错误2001您取消了上一个操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!