Office中国论坛/Access中国论坛

标题: 类型不对错误 [打印本页]

作者: pho    时间: 2006-4-25 00:07
标题: 类型不对错误
收入汇总表结构
khjl 文本
byfy 数字
syfy    数字

Private Sub front_30hz_Click()
    Dim sr(11) As String '声明一个整型变量
    Dim intI, intJ As Integer '声明一个整型变量
    Dim dblSYFY, dblBYFY As Double
    Dim strsql As String


    Set db = CurrentDb()
    Set recName = db.OpenRecordset("select * from 片区经理")

    Set strName = recName![xm]

    intI = 0
    Do Until recName.EOF
       sr(intI) = strName
       intI = intI + 1
       recName.MoveNext
    Loop
    recName.Close

    For intI = 0 To 10

        Set recName = db.OpenRecordset("select sum(总金额a),sum(上月费用a) into " + dblBYFY + "," + dblSYFY + "," + " from 客户清单 where 经理名称='" + sr(intI) + "' ")
        Set recName = db.OpenRecordset("select top 30 * from 客户清单 where 经理名称='" + sr(intI) + "' ")
        
        For intJ = 0 To 29
            Set strName = recName![总金额a]
            Set strName1 = recName![上月费用a]
            dblBYFY = dblBYFY + strName
            dblSYFY = dblSYFY + strName1
            recName.MoveNext
        Next intJ
        
         Next intI
    recName.Close
End Sub

执行到Set recName = db.OpenRecordset("select sum(总金额a),sum(上月费用a) into " + dblBYFY + "," + dblSYFY + "," + " from 客户清单 where 经理名称='" + sr(intI) + "' ")
这句话提示类型不对,不知道是哪个类型不对?请高手指点。


[此贴子已经被作者于2006-4-24 17:22:15编辑过]


作者: fan0217    时间: 2006-4-25 01:13
你用下面的语句试试呢?可能是你的数字型参数使用了单引号引起来产生的错误吧.

strsql = "insert into 收入汇总表 (khjl,byfy,syfy) values(" + sr(intI) + dblBYFY + "," + dblSYFY + ")"   

Set recName = db.OpenRecordset("select sum(总金额a),sum(上月费用a) into " + dblBYFY + "," + dblSYFY + "," + " from 客户清单 where 经理名称=" + sr(intI) )





欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3