VBA如何根据字母数字模式规则检查用户输入

时间:2018-11-29 06:55:20

标签: vba validation ms-access

我想验证一个字段,以检查它是否满足字母数字规则的组合。提交表单后出现的错误是“参数不可选”

Dim db As Database
Dim rs As Recordset
Dim myRegExp As RegExp
Dim myMatches As MatchCollection
Dim myMatch As Match
Set myRegExp = New RegExp
myRegExp.Global = True
myRegExp.pattern = "[a-zA-Z0-9]$"
Set myMatches = myRegExp.Execute(Me.NRIC)

 If Not myMatches Then
    MsgBox "NRIC/FIN must be combination of numeric and letter!"
    Cancel = True
    Me.NRIC.SetFocus
 End If

0 个答案:

没有答案