Access 用户登录窗体 中 用户ID 代码编写错误 请教高手解决

来源:百度知道 编辑:UC知道 时间:2024/06/07 07:13:46
Private Sub 用户ID_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_用户ID_BeforeUpdate
'使用Len函数判断在"用户ID"文本框输入的值是否为4个字符
If Len(Me![用户ID]) <> 4 Then
'如果不是,则弹出"用户ID错误"信息
'MsgBox " "用户ID"是四位数字组成! ",vbInformation,"用户ID错误"
'把Cancel参数值设置"真"
'这样可以使其他函数过程代码不执行,如"更新后"事件过程
Cancel = True
End If
Exit_用户ID_BeforeUpdate:
Exit Sub
Err_用户ID_BeforeUpdate
MsgBox Err.Description
Resume Exit_用户ID_BeforeUpdate
End Sub

Private Sub 用户ID_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_用户ID_BeforeUpdate
'使用Len函数判断在"用户ID"文本框输入的值是否为4个字符
If Len(Me![用户ID]) <> 4 Then
'如果不是,则弹出"用户ID错误"信息
'MsgBox " "用户ID"是四位数字组成! ",vbInformation,"用户ID错误"
'把Cancel参数值设置"真"
'这样可以使其他函数过程代码不执行,如"更新后"事件过程
Cancel = True
End If
Exit_用户ID_BeforeUpdate:
Exit Sub
Err_用户ID_BeforeUpdate
MsgBox Err.Description
Resume Exit_用户ID_BeforeUpdate
End Sub