ID验证 [英] ID validation

查看:76
本文介绍了ID验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用于Id验证的代码。 ID在文本框中输入,并验证命令按钮的GotFocus事件中的条目。但是,当我将它用于Label对象中的GotFocus时,它不起作用。它给出了一条错误消息运行时错误3251,此类对象不支持操作。在语句中:Rst.FindFirst" [CID] =" &安培; Me.txtReps

以下是完整的GotFocus功能。应该改变什么来使它工作?谢谢。

I have this code for Id validation. The ID is entered in a text box, and validates the entry in GotFocus event of a command button. However, it does not work when I use it for the GotFocus in a Label Object. It is giving me an error message "Run time error 3251, Operation is not supported for this type of object".in statement the: Rst.FindFirst "[CID] = " & Me.txtReps
Below is the complete GotFocus function. What should be changed to make it work? Thanks.

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

推荐答案

我必须告诉你,你不是很重要这里发布的内容完全没有意义!

I have to tell you, not much of what you''ve posted here makes any sense at all!


在文本框中输入ID,并在命令的GotFocus事件中验证条目按钮。
The ID is entered in a text box, and validates the entry in GotFocus event of a command button.



因此,您在文本框中输入ID,然后通过 焦点放在命令上来验证它按钮,而不是点击按钮?这绝对没有意义!

数据验证通常在文本框的 BeforeUpdate 事件中完成(如果您想立即反馈)或者以 BeforeUpdate 的形式完成如果您只是想知道何时准备保存记录。


至于为什么你得到"错误3251,不支持操作对于这种类型的对象,我在猜测,尽管这条线是'hilited(Access并不总是非常准确)',因为标签无法获得焦点!更令人困惑的是,你说这个代码是用于标签,但是子名称为


Sub Text 21_GotFocus


对大多数人来说,这是一个文本框。


Linq ; 0)>

So you enter the ID in your textbox, then you validate it by placing the focus on a command button, not by clicking on the button? This makes absolutely no sense!
Validation of data is usually done in the BeforeUpdate event for the textbox (if you want immediate feedback) or in the form''s BeforeUpdate event, if you only want to know when you''re getting ready to save the record.

As for why you get the "Error 3251, Operation is not supported for this type of object," I''m guessing, despite the line that''s hilited (Access isn''t always terribly accurate with this) that''s because a Label cannot receive focus! More confusing, you say this code is for a label, yet the sub is named

Sub Text21_GotFocus

which to most people would say that it''s a textbox.

Linq ;0)>



我有这个代码用于Id验证。 ID在文本框中输入,并验证命令按钮的GotFocus事件中的条目。但是,当我将它用于Label对象中的GotFocus时,它不起作用。它给出了一条错误消息运行时错误3251,此类对象不支持操作。在语句中:Rst.FindFirst" [CID] =" &安培; Me.txtReps

以下是完整的GotFocus功能。应该改变什么来使它工作?谢谢。

I have this code for Id validation. The ID is entered in a text box, and validates the entry in GotFocus event of a command button. However, it does not work when I use it for the GotFocus in a Label Object. It is giving me an error message "Run time error 3251, Operation is not supported for this type of object".in statement the: Rst.FindFirst "[CID] = " & Me.txtReps
Below is the complete GotFocus function. What should be changed to make it work? Thanks.

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



我必须告诉你,你在这里发布的内容并不重要!



所以你在文本框中输入ID,然后验证它通过 焦点放在命令按钮上,而不是点击按钮?这绝对没有意义!

数据验证通常在文本框的 BeforeUpdate 事件中完成(如果您想立即反馈)或者以 BeforeUpdate 的形式完成如果您只是想知道何时准备保存记录。


至于为什么你得到"错误3251,不支持操作对于这种类型的对象,我在猜测,尽管这条线是'hilited(Access并不总是非常准确)',因为标签无法获得焦点!更令人困惑的是,你说这个代码是用于标签,但是子名称为


Sub Text 21_GotFocus


对大多数人来说,这是一个文本框。


Linq ; 0)>
I have to tell you, not much of what you''ve posted here makes any sense at all!



So you enter the ID in your textbox, then you validate it by placing the focus on a command button, not by clicking on the button? This makes absolutely no sense!
Validation of data is usually done in the BeforeUpdate event for the textbox (if you want immediate feedback) or in the form''s BeforeUpdate event, if you only want to know when you''re getting ready to save the record.

As for why you get the "Error 3251, Operation is not supported for this type of object," I''m guessing, despite the line that''s hilited (Access isn''t always terribly accurate with this) that''s because a Label cannot receive focus! More confusing, you say this code is for a label, yet the sub is named

Sub Text21_GotFocus

which to most people would say that it''s a textbox.

Linq ;0)>



嗨。不要混淆。

你是对的,该函数在原始帖子中提到的用作命令按钮。只是现在我不想让用户选择,只需按Enter键,焦点就会返回到文本框以输入另一个ID。


标签确实得到了关注。在用户在组合框中输入项目编号的其他功能之一中,验证在其旁边的标签的GotFocus事件中完成。您无法在进行输入的对象中进行验证,因为您无法将焦点设置回自身。 Text21只是一个名字,对于命名约定很抱歉,我将它改为lblCommentID。


我需要帮助的原因是我使用了相同的代码,更改了对象名称,并使用Label而不是Command按钮,但我收到错误消息。也许有人可能知道如何修改代码以使其工作。但无论如何,谢谢。

Hi. Don''t get confused.
You are right, the function was used as, mentioned in the original posting, for a command button. Only now I don''t want the user to choose but just press enter and the focus is brought back to the Text box to enter another ID.

Labels do receive focus. In one of the other fucntions where the user enters an item number in a Combo box, the validation is done in a GotFocus event of the Label next to it. You cannot make the validation in the object where you make the entry because you cannot set focus back to itself. Text21 is just a name, sorry for the naming convention, I ''ll change it to lblCommentID.

The reason why I need help is that I used the same codes, changed object names, and using a Label instead of Command button, but I am getting the error message. Maybe there is someone out there who may know how to revise the codes to make it work. But thanks anyway.


这篇关于ID验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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