Office中国论坛/Access中国论坛
标题:
如何实现同时输入多个条件的模糊查询源码!
[打印本页]
作者:
sdlhlsd
时间:
2002-6-14 22:10
标题:
如何实现同时输入多个条件的模糊查询源码!
在用ACCESS编程中,若你想同时查询多个条件,例如:
在一张数据表中,
-----------------------
|地区|客户|销售额|数量|
|---------------------|
|上海|A |8000 |500 |
|北京|B |6000 |600 |
|江苏|C |5000 |300 |
|浙江|D |2000 |300 |
-----------------------
若在以上这个表中,我想同时查找上海与北京的销售情况,则可以利用mlike函数
为:mlike(上海;北京)如此输入即可;mlike函数如下
Function mLike(Param As Variant, Cond As Variant) As Boolean
On Error GoTo mLike_Err
Dim stn As String, stl As String, n As Integer, stlen As Integer
Dim stParam As String, stCond As String
If IsNull(Param) Or IsNull(Cond) Then
mLike = False
Exit Function
End If
stParam = Trim$(UCase$(Param))
stCond = Trim$(UCase$(Cond))
If stParam Like stCond Then
mLike = True
Exit Function
End If
stn = Trim$(stCond)
stlen = Len(stCond)
n = InStr(1, stn, ";")
While n <> 0
If stParam Like stn Then
mLike = True
Exit Function
End If
n = InStr(1, stn, ";")
If n <= 1 Then
mLike = False
Exit Function
End If
stl = Left$(stn, n - 1)
stn = Right$(stn, stlen - n)
stlen = Len(stn)
If stParam Like stl Then
mLike = True
Exit Function
End If
Wend
mLike = False
Exit Function
mLike_Err:
MsgBox "Error In mLike....." & Err.Description
mLike = False
Exit Function
End Function
作者:
youshanzx
时间:
2002-6-15 06:57
又学一招,谢谢了!
------------------------------------
勿以恶小而为之,勿以善小而不为
作者:
zhuyiwen
时间:
2002-6-15 07:37
好,收藏!
作者:
chengweibing
时间:
2002-6-15 23:20
高手所体现的心灵之美!!!谢谢了……
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3