Private Sub partcode_AfterUpdate()
Dim a, b As String
Dim i, j As Integer
j = Len(Me.partcode)
i = 1: b = ""
Do Until i > j
If 97 <= Chr(Mid(Me.partcode, i, 1)) <= 122 Then
MsgBox "请输入“部品代码”,它不可以为小写字母!", vbOKOnly, "输入“部品代码”"
Me.partcode.SetFocus
Exit Sub
ElseIf 65 <= Chr(Mid(Me.partcode, i, 1)) <= 90 Then
a = Mid(Me.partcode, i, 1)
b = b & a
ElseIf 48 <= Chr(Mid(Me.partcode, i, 1)) <= 57 Then
Exit Do
End If
i = i + 1
Loop
Me.material = Nz(DLookup("material", "partcode", "partcode=" & b & ""), Null)
End Sub
Function DelNum(Str) As String
If Len(Str) > 0 Then
For i = 1 To Len(Str)
DelNum = IIf(IsNumeric(Mid(Str, i, 1)), DelNum, DelNum & Mid(Str, i, 1))
Next
End If
End Function