在用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 |
|站长邮箱|小黑屋|手机版|Office中国/Access中国
( 粤ICP备10043721号-1 )
GMT+8, 2025-4-2 12:12 , Processed in 0.234907 second(s), 24 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.