Set Rs = cnnMDB.Execute("select max(金额) as AAAA  from 支出" & " where  datediff('d',[日期],'" & Month(Date) & "-1" & "')<=0 and datediff('d',[日期],'" & Format$(Date, "General Date") & "')>=0")
      msgbox Rs.Fields("AAAA")
      为什么结果不是​当月的最大值?????

解决方案 »

  1.   

    Set Rs = cnnMDB.Execute("select max(A.金额) as AAAA  from (SELECT * FROM 支出 where  Month([日期])=Month(NOW)) AS A"
      

  2.   

    是查询本月当期记录吗?Set Rs = cnnMDB.Execute("select max(金额) as AAAA  from 支出" & " where 日期 >= #" & Format(Date, "yyyy-mm") & "-01# And 日期<#" & Format(Date+1, "yyyy-mm-dd") & "#")
      

  3.   

    Set Rs = cnnMDB.Execute("select max(金额) as je  from  支出 where  Month([日期])=" &  Month(NOW)