Public Function F(SVal As String) As Double
Dim TmpSum As Double
    TmpSum = 0
    MySql = "select price,item_name from items  where parent='" & SVal & "'"
    If sqlReset(MySql) Then
        Dim TmpReset As ADODB.Recordset
        'Set TmpReset = New ADODB.Recordset
        Set TmpReset = myReset.Clone
        While Not TmpReset.EOF
            TmpSum = TmpReset!price + F(TmpReset!item_name)
        Wend
        Set TmpReset = Nothing
    End If
    F = TmpSum
End Function
在执行时老是说当前记录集不支持书签,这可能是提供程序或选定的游标限制。
哪位老哥帮帮我!

解决方案 »

  1.   

    'Set TmpReset = New ADODB.Recordset
    前面为什么要加一个注释?
      

  2.   

    Set TmpReset = myReset.Clone ''这句有错误,修改为
    Set TmpReset = myReset
      

  3.   

    sqlReset()和myReset对象不明确,是什么东东检查函数sqlReset内打开数据集时的参数你的函数箱实现什么功能?我看好像算法可以简化
      

  4.   


    Dim TmpReset As ADODB.Recordset
    Set TmpReset = myReset.Clone
    这样的复制记录集的语句并没有任何错误-----------------------
    sqlReset(MySql)  请检查你这个函数,可能是你记录集打开的问题
      

  5.   

    myReset  这个记录集你是怎么写的?
      

  6.   

    如果字段数相同,每个字段的属性也相同的话,可以将其追加到另一个记录集中,
    MRC1.movelast
    mrc2.movefirst
    do while not mrc2.eof
    mrc1.addnewmrc1.fields("字段名").value = mrc2.fields("字段名").value
    .
    .
    .
    mrc1.update
    mrc2.movenext
    mrc1.movenext
    loop
      

  7.   

    谢谢,各位问题解决了。
    myreset()与sqlreset()是我自己定义的两个函数,可以直接带入SQL语句返回记录集,
    很方便,
    还有几个函数有点长不贴出来了,如果想看看请妹:[email protected]
      

  8.   

    Dim cmd As Command
        Dim cmd1 As Command
        Dim rs As Recordset
        Dim rs1 As Recordset
        Dim sqlstr As String
        Dim sqlstr1 As String
        Dim datenow As Date
        Dim i As Integer
        Dim a As Integer
        
        
        Set cmd = New Command
        Set cmd1 = New Command
        
        If de_holdsale.Connection1.State = adStateClosed Then
            de_holdsale.Connection1.Open
        End If
        If de_holdsale.cnn.State = adStateClosed Then
            de_holdsale.cnn.Open
        End If
        cmd.ActiveConnection = de_holdsale.Connection1
        cmd1.ActiveConnection = de_holdsale.cnn
        
        datenow = dtpnow.Value
        
        sqlstr = "select fitemno,flotno,flotno2,fwhcd,flctcd,fohqty from invdtf where fohqty>0"
        
        cmd.CommandText = sqlstr
        Set rs = cmd.Execute
        prgload.Max = rs.RecordCount
    '    Label1.Caption = "处理中..."
        
        For i = 1 To rs.RecordCount
            prgload.Value = i
    '        Label2.Caption = i
            sqlstr1 = "insert into dayinvdtf(fitemno,flotno,flotno2,fwhcd,flctcd,fohqty,fdate) " _
             & " values('" & rs!fitemno & "','" & rs!flotno & "','" & rs!flotno2 & "'," _
             & " '" & rs!fwhcd & "','" & rs!flctcd & "','" & rs!fohqty & "','" & datenow & "')"
            cmd1.CommandText = sqlstr1
            cmd1.Execute
            rs.MoveNext
        Next i
        
        MsgBox "处理完毕!", vbOKOnly
    '    a = "共添加了" + rs.RecordCount + "条记录"
     '   Label3.Caption = a
        
        Set rs = Nothing
      

  9.   

    Dim cmd As Command
        Dim cmd1 As Command
        Dim rs As Recordset
        Dim rs1 As Recordset
        Dim sqlstr As String
        Dim sqlstr1 As String
        Dim i As Integer
        Dim a As Integer
        
        
        Set cmd = New Command
        Set cmd1 = New Command
        
        
        If de_holdsale.cnn.State = adStateClosed Then
            de_holdsale.cnn.Open
        End If
        cmd.ActiveConnection = de_holdsale.cnn
        cmd1.ActiveConnection = de_holdsale.cnn
        
        sqlstr = "select ......"
        
        cmd.CommandText = sqlstr
        Set rs = cmd.Execute
        
        For i = 1 To rs.RecordCount
            sqlstr1 = "insert ......"
            cmd1.CommandText = sqlstr1
            cmd1.Execute
            rs.MoveNext
        Next i
        
        MsgBox "处理完毕!", vbOKOnly    Set rs = Nothing这样看起来比较好