如何处理表记录的文本框验证? [英] How to deal with textbox validation to table records?

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

问题描述

Private Sub txtUserCode_Validate(Cancel As Boolean)

If RS!ID = txtUserCode.Text Then

SQL = "SELECT NAME,PRIVILEDGE FROM ADMIN WHERE CODE=" & txtUserCode.Text
    Set RS = CN.Execute(SQL)
    txtUserName.Text = RS!NAME
Else
    MsgBox "ENTER VALID NO"
            txtUserCode.Text = ""
                        Cancel = True
End If
End Sub





在此代码我想执行如下:



[1]如果我输入表格中的ID,那么它将显示信息,但它正在考虑第一条记录( RS!ID(0))只不是下一个



[2]如果我输入表中没有的ID那么它就不会扔错误

3021-请求的操作需要电流nt记录但转到其他部分。



请帮助........



In this code I want to execute like:

[1] If I enter the ID present in table then it''ll show info but it''s considering 1st record (RS!ID(0)) only not the next one

[2] If I enter the ID which is not present in table then it sh''d not throw error
"3021- Requested operation requires current record" but goto else part.

Please help........

推荐答案

我添加了以下条件

如果RS.Fields(0)& =然后

请尝试以下代码





I have added a following condition
If RS.Fields(0) & "" = "" Then
Please Try following code


Private Sub txtUserCode_Validate(Cancel As Boolean)

If RS!ID = txtUserCode.Text Then

SQL = "SELECT NAME,PRIVILEDGE FROM ADMIN WHERE CODE=" & txtUserCode.Text
    Set RS = CN.Execute(SQL)

    If RS.Fields(0) & "" = "" Then
      MsgBox "ENTER VALID NO"
      txtUserCode.Text = ""
      Cancel = True
    ELSE
     txtUserName.Text = RS!NAME
    End If

End Sub


这篇关于如何处理表记录的文本框验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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