如何在编辑之前捕获表单变量 [英] How do I capture Form Variables before editing them

查看:57
本文介绍了如何在编辑之前捕获表单变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用表单来显示约会记录列表。我想从列表中选择一条记录并编辑字段。然而。我希望在编辑之前捕获记录字段,因为我需要此信息以便随后删除旧的Outlook约会。


我尝试使用之前的编辑事件捕获此信息并将结果声明为模块中的公共变量。


然而,当我尝试回忆Public变量时,它们显示为空。


这是因为之前的编辑Sub是否在同一个类模块中?或者我做了一些愚蠢的事情。

I am using a form to show a list of Appointment records. I want to choose a record from the list and edit the fields. However. I wish to capture the record fields before editing as I need this information to subsequently delete the old Outlook appointment.

I have tried capturing this info using the before edit Event and have declared results as Public variables in a Module.

However, when I try to recall the Public variables they are showing empty.

Is this because the before edit Sub is within the same class module? or am I doing something stupid.

推荐答案

我们假设您希望在编辑之前捕获表单上的名字,MI和姓氏值。
Let''s assume that you wish to Capture the First Name, MI, and Last Name Values on a Form prior to Editing.
  1. 在标准代码模块中将变量声明为公共
  1. Declare your Variables as Public in a Standard Code Module
展开 | 选择 | 换行 | 行号


如果你展示了你正在使用的代码并解释了它失败时发生了什么,那将会更加容易。我想我可以猜到,但我可能错了 - 我不明白为什么我们必须继续猜测什么时候会有更多的关心和准备会提出一个完整的问题。


我怀疑你的公共变量是在类或对象(Form或Report)模块中声明的。这些模块可以声明公共变量,但是当从同一模块的外部访问它们时,需要明确引用它们。假设变量在模块中声明为名为frmMain的表单,并且变量本身名为strName,那么对它们的完整引用将是Form_frmMain.strName。正如您从早期的线程中所知,这不能从SQL引用。没有公共变量可以。


PS。对于在没有模块说明符的情况下在代码中的任何位置引用的变量,需要在标准模块中声明。
This would be so much easier if you showed the code you''re using and explained what happened when it failed. I think I can guess, but I may be wrong - and I don''t see why we have to keep guessing when a bit more care and preparation would make a full question.

I suspect you public variables have been declared in a class or object (Form or Report) module. Such modules can declare public variables, but when they are accessed from outside of that same module, they need to be referenced explicitly. Assuming the variable is declared as public in the module for a form named "frmMain", and the variable itself is named strName, then the full reference to them would be Form_frmMain.strName. As you know from an earlier thread, this cannot be referenced from SQL. No public variables can.

PS. For a variable to be referenced anywhere in your code without the module specifier, it needs to be declared in a Standard Module.


Hi Adezii


谢谢你。我已经放置了你的代码,但是我使用的是2个日期字段,并且不确定如何对这些字段进行初始化,并且在oldDate字段上出现错误。


我的代码是
Hi Adezii

Thanks for this. I have placed your code but I am using 2 date fields and not sure how to intitialise these and am getter an error on the oldDate field.

My Code is
展开 | 选择 | Wrap | 行号


这篇关于如何在编辑之前捕获表单变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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