通过VBA更改文本框的必需属性 [英] Change Required property of textbox via VBA

查看:448
本文介绍了通过VBA更改文本框的必需属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我有一个表单,其中包含一些控件,其属性已按表中的要求列出,因为它们始终处于启用状态。该表格还有一个标有结果的组合框。根据在该组合框中选择的内容,更改要启用的其他文本框。我想做的是确保启用任何文本框都是必需的。这可能吗?这是我的结果组合框的代码

展开 | 选择 | Wrap | 行号

解决方案

Elaine,


我会为你的组合框使用一个Select Case语句,它会阻止If ... Then语句的永久嵌套。这也可以更容易地为组合框添加其他值:

展开 | 选择 | Wrap | 行号


另外:

---

-命名字段,表格和文件时最好的做法是避免使用除字母数字字符和下划线之外的任何内容(尽管允许空格有问题)从编程的角度来看并且最好避免)并且避免所有保留的单词和标记(例如时间或%等)非常重要:
访问2007保留字和符号
AllenBrowne-访问中的问题名称和保留字词


您好,


感谢您的回复。确实,我有很多东西需要学习。我刚开始在5月中旬开始自学Access这个项目并且必须在下周五完成它,所以不幸的是,彻底改革不会发生。但是,我一定会看看那个链接。我一直在尝试阅读/观看尽可能多的教程(甚至编写了傻瓜编码)。


很高兴知道Select Case ...确实所有的If ..然后变得讨厌。


关于我的问题,我道歉它不是很清楚。这是我的主要形式。表单的上半部分有9个控件,它们始终处于启用状态,必须在表单关闭之前输入。这些字段都设置为表中所需。为了获得一个想法,这个表格适用于希望为他们提供翻译/翻译的客户,上半部分被视为一个入口,我们输入客户信息,他们需要服务的日期,如果他们想要一个翻译/翻译者,他们想要的语言等等。因此,当首次输入案例时,结果将是等待。除非服务发生在请求的同一天。


提供服务后,我们再次提起案件并更改结果。解释或翻译。结果更改后,其他控件将启用,例如谁提供服务,实际提供的日期,花费的时间,成本等。一旦启用这些字段,它们也应该在表单之前被要求可以保存。但是,现在,表格即使没有填写也可以保存和关闭。我想阻止用户只是改变结果。状态(会关闭案例)而不填写其他字段。


我希望这能清除我想做的事情。谢谢!

Hello,

I have a form that has some controls whose properties are already listed as required in the table, as they are always enabled. The form also has a combo box labeled "Outcome" that changes other textboxes to be enabled depending on what is chosen in that combo box. What I would like to do, is make sure that whatever textboxes are enabled are also required. Is this possible? Here is my code for the Outcome combo box

Expand|Select|Wrap|Line Numbers

解决方案

Elaine,

I would use a Select Case Statement for your Combo Box, which prevents the eternal nesting of If...Then statements. This would also make it easier to add additional values to your combo box.:

Expand|Select|Wrap|Line Numbers


additionally:
---
-It is best practice when naming fields, tables, and files to avoid the use of anything other than alphanumeric characters and the underscore (spaces although allowed are problematic from a programing point of view and best avoided) and it is VERY importaint to avoid all reserved words and tokens (such as "Time" or "%" etc):
Access 2007 reserved words and symbols
AllenBrowne- Problem names and reserved words in Access


Hello,

Thanks for the reply. Indeed I have a lot to learn. I just started teaching myself Access with this project mid May and have to have it complete by next Friday, so unfortunately, a complete overhaul is not gonna happen. However, I will definitely look at that link. I have been trying to read/watch as many tutorials as possible (even got a coding for dummies).

Good to know about the Select Case...indeed all the If...Then was getting annoying.

In regards to my question, I apologize it wasn''t very clear. This is for my main form. The top half of the form has 9 controls that are always enabled and must be entered before the form can close. These fields are all set to required in the table. To get an idea, this form is for clients who wish to have an interpreter/translator provided to them and the top half is treated like an intake, where we enter the client information, the date they need the service, if they want an interpreter/translator, the language they want, etc. So when the case is first entered, the outcome will be "Pending" unless the service happened the same day as the request.

After the service is provided, we pull up the case again and change the "outcome" to interpretation or translation. Upon the outcome change, other controls become enabled, such as who provided the service, the date it actually was provided, the amount of time it took, the cost, etc. Once these fields are enabled, they should also be required before the form can be saved. However, right now, the form can be saved and closed even if they aren''t filled out. I would like to prevent the users from just changing the "outcome" status (which would close the case) and not filling in the other fields.

I hope this clears up what I would like to do. Thanks!


这篇关于通过VBA更改文本框的必需属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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