在用ACCESS編程中,若你想同時查詢多個條件,例如: 在一張數(shù)據(jù)表中, ----------------------- |地區(qū)|客戶|銷售額|數(shù)量| |---------------------| |上海|A |8000 |500 | |北京|B |6000 |600 | |江蘇|C |5000 |300 | |浙江|D |2000 |300 | ----------------------- 若在以上這個表中,我想同時查找上海與北京的銷售情況,則可以利用mlike函數(shù) 為:mlike(上海;北京)如此輸入即可;mlike函數(shù)如下 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-7-17 01:00 , Processed in 0.133226 second(s), 23 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.