Private Sub FIdenCardNo_BeforeUpdate(cancel As Integer)
Dim strPara As String
Dim j As Integer
Dim rs As DAO.Recordset
' 之前是强制 判断是15 或18 位,后来将 这个长度 设置为一个参数保存在参数表中 ,参数值为: 15,18,10
' If Len(Nz(FIdenCardNo)) <> 18 And Len(Nz(FIdenCardNo)) <> 15 Then
' gt_MessageBox "身份证号码必须为18位为15位"
' cancel = True
' Exit Sub
'
'
' End If
If Nz(FIdenCardNo) <> "" And (Nz(FIdenCardNo.OldValue) <> Nz(FIdenCardNo.Value)) Then
Set rs = CurrentDb.OpenRecordset("Select * from tblHrmEmp where FIdenCardNo='" & Me.FIdenCardNo & "' and FEmpStatusId<>'4'")
If rs.RecordCount > 0 Then
gt_MessageBox "此员的身份证号码与在职的另一个员工:" & rs("FEmpCode") & " " & rs("FEmpName") & "重复!" & vbCrLf & "请重新输入!"
cancel = True
End If
rs.Close
Set rs = CurrentDb.OpenRecordset("Select * from tblHrmEmpHist where FIdenCardNo='" & Me.FIdenCardNo & "'")
If rs.RecordCount > 0 Then
If gt_MessageBox("身份证号码与离职库中另一个员工:" & rs("FEmpCode") & " " & rs("FEmpName") & " 有重复 ,是否继续?", 2) = vbNo Then
cancel = True
Exit Sub
End If
End If
rs.Close
End If
If Nz(DLookup("FIdenCardNo", "tblHrmBlacklist", "FIdenCardNo='" & Me.FIdenCardNo & "'")) <> "" Then
MsgBox "此身份证[" & Me.FIdenCardNo.Value & "]与黑名单中一致,不能保存!", vbInformation, "提示"
cancel = True
Exit Sub
End If
' If Nz(Me.FIdenType) = "身份证" Then
strPara = gt_GetSysPara("AllowMaxIdenLen")
'strPara = DLookup("FSysParaValue", "tblZstmParameter", "FSysParaName='AllowMaxIdenLen'")
Dim varPara As Variant
Dim intLen As Integer
Dim blnOk As Boolean
varPara = Split(strPara, ",") ' 取参数值,参数值为: 15,18,10
intLen = Len(FIdenCardNo.Value)
For j = 0 To UBound(varPara)
If intLen = Val(varPara(j)) Then
blnOk = True
Exit For
End If
Next
If blnOk = False Then
gt_MessageBox "身份证号码长度不对"
cancel = True
End If