表格after_update没有开火= [ [英] Form after_update not firing =[

查看:63
本文介绍了表格after_update没有开火= [的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一个奇怪的问题,可能只是我的代码中的一些东西我完全没有。


基本上我用的表单中子表单上的类似代码和更新后事件正确运行。


但是使用以下代码后,更新后不会触发。我添加了一个msgbox来查看确切的信息并且msgbox没有加载,所以事件不是很明显。


此代码位于我的主窗体上的子窗体subfrmcorrective中:

展开 | 选择 | Wrap | 行号

解决方案

你好克里斯。不能告诉你发布了什么,但看起来你的Before_Update例程可能导致Update事件被取消。


您在Before_Update中的测试对我来说似乎不对;例如

展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


验证工作正常,即使是我已经列出的日期,我也使用了len只是为了看看是否有任何东西进入该领域。我有每个验证的cancel = true设置只发生1,可能是任何。我想我可以将cancel = true移动到后面的语句中,我会检查errorstring的长度以查看是否添加了任何错误消息。


但我不认为这是哪里我的问题是在更新之前。如果我单步执行我的代码,确保我的表单中没有无效条目它从保存按钮单击甚至通过before_update运行完全正常,然后在单击保存事件结束时退出sub。但似乎没有涉及更新后的任何内容。


感谢您指出设计不佳,我自学成才,所以我发现这是我做的大部分内容。 />

编辑:刚刚看到了编辑,我认为当我发现len<时,我最后通过懒惰抛弃了IsNull。 1似乎给了我相同的结果(我可以继续快速复制代码块以检查实际需要超过设定量的长度)。但是,如果这是不正确的,你建议我认为我应该改变它。


编辑2:刚刚意识到我在beforeupdate事件中没有防错,所以只是为了提醒自己添加在明天。


你好克里斯。如果Before_Update正在触发,但After_Update不是,则在Before_Update中发生了取消事件的事情 - 否则After_Update事件肯定会触发。您会注意到After_Update没有取消参数 - After_Update一旦被引发就无法取消。


如果您对此不确定,我建议您注释掉整个before_update事件代码并对表单下的数据进行更改;你几乎肯定会看到你在After_Update中出现的消息框,除非我们还不知道其他因素在玩!


-Stewart

Hi all,

I have a weird problem and likely just something in my code I am missing completely.

Basically I use similar code on sub form within a form and the after update event runs correctly.

However with the following code the after update will not fire. I have added a msgbox to see exactly and the msgbox does not load so clearly the event isn''t.

This code resides in a subform subfrmcorrective on my main form:

Expand|Select|Wrap|Line Numbers

解决方案

Hi Chris. Can''t tell much from what you''ve posted, but it appears likely that your Before_Update routine is causing the Update event to be cancelled.

Your tests in the Before_Update don''t seem right to me; for example

Expand|Select|Wrap|Line Numbers


The validation works correctly, even with the dates as I have set out I use the len just to see if anything has been entered in to the field. I have the cancel = true set for each validation incase only 1 occurs which could be any. I guess I could move the cancel = true to the later statement where I check the length of errorstring to see if any error messages have been added.

However I do not think this is where my issue is with the before update. If I step through my code ensuring there is no invalid entries in my form It runs through perfectly fine from the save button click even, through before_update and then exit subs back at the end of the on click save event. But there doesnt seem to be any after update involved.

Thank you for pointing out poor design, I am self taught so I find this is a given with most of what I do

Edit: Just saw ure edit, I think I ended up ditching IsNull through laziness when I found that len < 1 appeared to give me the same result (and I could keep copying the code block quickly to check lengths that were actually required to be above a set amount). However if this is incorrect as you suggest I think I should be changing it.

Edit2: Just realised I have no error proofing within my beforeupdate event so just to remind myself to get that added in tomorrow.


Hi Chris. If Before_Update is firing but After_Update is not then something is happening in Before_Update which is cancelling the event - otherwise the After_Update event would definitely fire. You''ll notice there is no Cancel parameter for After_Update - After_Update cannot be cancelled once it is raised.

If you are uncertain about this I''d suggest that you comment out the whole of your before_update event code and make a change to the data underlying your form; you are almost certain to see the message box you''ve placed in the After_Update appear unless there are other factors we don''t know of in play!

-Stewart


这篇关于表格after_update没有开火= [的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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