DCount("*","表1","早餐=包子")+DCount("*","表1","中餐=包子")+DCount("*","表1","晚餐=包子")DCount("*","表1","夜宵=包子")
Select ID, 早餐 AS Dinner FROM 表1
Union Select ID, 午餐 AS Dinner FROM 表1
Union Select ID, 晚餐 AS Dinner FROM 表1
Union Select ID, 夜宵 AS Dinner FROM 表1
Public Function MCount(FieldFrom As Integer, Field To As Integer, FieldValue As Variant) As Long
Dim intFieldID As Integer
Dim adoRs As New ADODB.Recordset
adoRs.Open "SELECT * FROM 表1", CurrentProject.Connection
Do Until adoRs.EOF
For intFieldID=FieldFrom To FieldTo
If adoRs.Fields(intFieldID)=FieldValue Then MCount=MCount+1
Next intFieldID
adoRs.MoveNext
Loop
End Function
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |