如果字段为空,则关闭表单会产生2585错误 [英] Close Form if Field is Blank Gives 2585 Error

查看:69
本文介绍了如果字段为空,则关闭表单会产生2585错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表单上,我有一个SSN和名称字段。如果SSN为空白,则在名称字段的On Got Focus中,它会查看是否存在SSN(根据另一个人的建议在下一个字段中执行此操作)。如果存在,则询问用户是否要转到该记录。是打开另一个表单,否关闭当前表单并转到主菜单(这很好)。如果SSN为NULL,它会告诉用户他们必须输入,并询问您是否要添加?是的 - 回到SSN领域(工作正常)。对于否,我希望它关闭当前表单。问题,我收到运行时错误2585.我一直在寻找如何解决此错误的日子。根据我的理解,表单上的进程仍在运行。我无法弄清楚如何阻止它。这是我的代码(是的 - 我已经尝试了许多变种而没有运气,但这是最后一个)。得到2585错误的代码是DoCmd.Close acForm,frmVetNewMainForm,acSaveNo。

On my form, I have a SSN and name field. If the SSN is blank, in the On Got Focus on the name field, it looks to see if SSN exists (did it on next field per suggestion from another person). If it exists, it asks the user if they want to go to that record. Yes opens another form, No closes current form and goes to main menu (this works fine). If the SSN is NULL, it tells the user they must enter, and asks do you want to add? Yes - goes back to SSN field (works fine). For No, I want it to close the current form. Problem, I am getting a run-time error 2585. I''ve been searching for days on how to fix this error. From what I understand, a process on the form is still running. I can''t figure out how to stop it. Here is my code (Yes - I have tried many variations without luck, but this is the last one). The code that''s getting the 2585 error is DoCmd.Close acForm, "frmVetNewMainForm", acSaveNo.

展开 | 选择 | Wrap | 行号

推荐答案

使用BeforeUpdate事件,然后取消事务。
Use the BeforeUpdate Event and then Cancel the transaction.


试过但是因为我没有输入任何名称(它是NULL),所以没有字段更新,因此BeforeUpdate和AfterUpdate不起作用。如果我确实输入名称,它确实有效。如果我将代码移动到SSN(我正在检查它是否为NULL),同样的情况也是如此,BeforeUpdate和AfterUpdate不起作用,因为你没有更新任何东西 - 它是' NULL。
Tried that but because I''m not entering anything into name (it''s NULL), there is no update on field so BeforeUpdate and AfterUpdate do not work. If I do enter something into name, it does work. The same goes if I move the code to SSN (it''s what I''m checking to see if it''s NULL), BeforeUpdate and AfterUpdate do not work because you aren''t updating anything - it''s NULL.


我确实尝试将000-00-0000放入SSN号码并检查,但仍然得到2585错误。我必须查看事件的顺序,以确定在更新之前有效的方法。在更新前的Key Down运行。仅供参考 - 仅仅因为其他人已经提出要求,以防用户点击其他字段,我确实要检查以确保在他们点击关闭按钮时有SSN。
I did try to put 000-00-0000 into SSN number and check for that, but still getting 2585 error. I had to look at the order of events to figure out what works before Before Update. On Key Down runs before Before Update. FYI - Just because others have asked, just in case a user clicks on other fields, I do have it checking to make sure there''s a SSN when they click the Close button.


这篇关于如果字段为空,则关闭表单会产生2585错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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