在CarryOver过程中排除控制字段 [英] Exclude Control Fields in CarryOver Procedure

查看:73
本文介绍了在CarryOver过程中排除控制字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Access表单,并希望我的大部分字段在前进到下一条记录时自动继续。我发现AllenBrowne.com上的代码运行良好,但无法成功获取调用命令以排除我不想转发到新记录的字段。


我试图模仿他为此目的提供的代码:
调用CarryOver(Me,strMsg," Notes"," EmployeeID")


...并收到以下错误消息:

"编译错误:错误的参数数量或无效的属性赋值


我目前工作的代码很简单:

I am building an Access form and want most of my fields to carry forward automatically when advancing to the next record. I found code on AllenBrowne.com that works well, but am unable to successfully get the call command to exclude fields that I DO NOT want carried forward to the new record.

I have tried to mimic the code that he provided for this purpose:
Call CarryOver(Me, strMsg, "Notes", "EmployeeID")

...and receive the following error message:
"Compile error: Wrong number of arguments or invalid property assignment"

My code that currently works is simply:

展开 | 选择 | Wrap | 行号

推荐答案

在第18行和第22行,您需要进行测试以确保控件不是'一个你不想搬过来的人。例如,假设您不希望将名为txtFirstName和txtLastName的控件移过:
On lines 18 and 22 you would need to test to make sure that the control isn''t one that you don''t want to move over. As an example, say you don''t want the controls named txtFirstName and txtLastName moved over:
展开 | 选择 | Wrap | 行号


Don''这些行是For i = 0 To frm.Count-1。和Set ctl = frm(i)和Set ctl = frm(i)自动循环遍历表单上的每个控件?


我应该在程序本身中使用if语句来排除我想要跳过的控件吗?有更好的方法吗?
Don''t the lines "For i = 0 To frm.Count-1" and "Set ctl = frm(i)" automatically cycle through every control on the form?

Should I be using an if statement in the procedure itself to exclude controls that I want skipped? Is there a better way?


是的,第15行会遍历表单上的每个控件,包括标签,按钮,子表单,选项卡控件等。这就是为什么第17行和第21行是包括这样只有当控件是文本框或组合框时才会发生某些事情。然后第18行和第22行确保这些控件中有某些东西。我添加的代码确保控件名称不是您想要排除的名称。
Yes, line 15 does loop through every control on your form, including labels, buttons, subforms, tab controls, etc. That is why lines 17 and 21 are included so that something happens only if the control is either a textbox or a combobox. Then lines 18 and 22 make sure that there is something in those controls. My added code makes sure that the control name isn''t one that you want excluded.


这篇关于在CarryOver过程中排除控制字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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