Dim find_date1 As String
Dim find_date2 As String
find_date1 = Trim(Combo1.Text) & "-" & Trim(Combo2.Text) & "-" & Trim(Combo3.Text)
find_date2 = Trim(Combo4.Text) & "-" & Trim(Combo5.Text) & "-" & Trim(Combo6.Text)
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select sum(金额) from 入库 where 日期 between #" & _
find_date1 & "#" & " and" & " #" & find_date2 & "#"
Adodc1.Refresh
我想将上面的这个查询出的总金额显示在text中,怎么能实现阿?帮忙写出代码,谢谢!

解决方案 »

  1.   

    Adodc1.RecordSource = "select sum(金额)as moeny from 入库 where 日期 between #" & _ 
    find_date1 & "#" & " and" & " #" & find_date2 & "#" 
     Set Text1.DataSource = Adodc1
    Text1.DataField = "money"
      

  2.   

    打错了
    Adodc1.RecordSource = "select sum(金额)as money from 入库 where 日期 between #" & _ 
    find_date1 & "#" & " and" & " #" & find_date2 & "#" 
    Set Text1.DataSource = Adodc1 
    Text1.DataField = "money"
      

  3.   

    或者直接Text1.Text = Adodc1.Recordset.Fields(0).Value
      

  4.   

    不要用datasource,直接用text1.text = rst.fields!aa
      

  5.   

    Adodc1.RecordSource = "select sum(金额) as 总金额 from 入库 where 日期 between #" & _ 
    find_date1 & "#" & " and" & " #" & find_date2 & "#" 
    Adodc1.Refresh Text1 = Adodc1.Recordset!总金额
      

  6.   

    来的晚了,谢谢大家帮助,是   (或者直接Text1.Text = Adodc1.Recordset.Fields(0).Value)这个可以实现。