步骤如下:
1、打开VBA(ALT+F11)
2、右键模块=》插入=》模块
3、粘贴以下代码:
Public Function CutStr(chkStr As String) As String
‘截取字符串中第一个数字符
Dim i As Long
For i = 1 To Len(chkStr)
If Mid(chkStr, i, 1) Like "[0-9]" Then
CutStr = Mid(chkStr, i, 1)
Exit Function
End If
Next i
CutStr = chkStr
End Function
4、保存,关闭VBA
5、在access中新建查询,在默认的语句后面增加where条件
SELECT ......FROM 表 where CutStr(字段)== 5
时间: 2024-11-06 09:43:18