“当对象打开时不允许操作”VB6中的错误

时间:2009-12-09 22:38:51

标签: vb6

当我尝试执行程序时,我收到的错误如“对象打开时不允许操作”。

我在代码的第二部分.Source = "SELECT * FROM t_data_Comments

中出现了错误
    Sub DneFroceClose() 
    Dim lngRecCount As Long

    frmDNELoad.lblStatus.Caption = "Updating records in Reclamation and Comments Table..."
    frmDNELoad.Refresh
    CqDate = Format(Date, "dd/MM/yyyy")

    Set rcdreclamation = New ADODB.Recordset
    With rcdreclamation
        .ActiveConnection = objConn
        .Source = "SELECT * FROM T_DATA_reclamation"
        .CursorType = adOpenDynamic
        .CursorLocation = adUseClient
        .LockType = adLockOptimistic
        .Open
    End With

    rcdDNE.MoveFirst
    rcdreclamation.MoveFirst 
    Do Until rcdDNE.EOF 
      Do Until rcdreclamation.EOF 
         If rcdDNE.Fields![AccountNbr] = rcdreclamation.Fields![RTProvided] Then
              rcdreclamation.Fields![ClaimStatus] = "C"
              rcdreclamation.Fields![DateClosed] = CqDate
              rcdreclamation.Fields![Audit_LastUpdated] = CqDate
              rcdreclamation.Fields![Audit_UserAdded] = "SYSTEM"
              rcdreclamation.Update
              Call DneComments
              Exit Do
         Else
         rcdreclamation.MoveNext
         End If 
      Loop
       rcdDNE.MoveNext
       rcdreclamation.MoveFirst 
    Loop 
End Sub 

    Sub DneComments() 
    With cmdDNEFRC
        .ActiveConnection = objConn
        .CommandText = "insert into t_data_Comments (ControlNbr, Audit_DateAdded, Audit_UserAdded, Description, EntryType) values ('" & rcdreclamation("ControlNbr") & "', '" & rcdreclamation("DateClosed") & "', '" & rcdreclamation("Audit_UserAdded") & "', 'Claim force-closed.', 'FORCE-CLS')"
        .CommandType = adCmdText
    End With

    Set rcdDneComments = New ADODB.Recordset
    With rcddnefrc
        .ActiveConnection = objConn
        .Source = "SELECT * FROM t_data_Comments"
        .CursorType = adOpenDynamic
        .CursorLocation = adUseClient
        .LockType = adLockOptimistic
        .Open
    End With

    With rcddnefrc
        .Requery
        .AddNew
        .Fields![ControlNbr] = rcdreclamation.Fields![ControlNbr]
        .Fields![Audit_DateAdded] = rcdreclamation.Fields![DateClosed]
        .Fields![Audit_UserAdded] = rcdDNE.Fields![Audit_UserAdded]
        .Fields![Description] = "Claim force-closed."
        .Fields![EntryType] = "FORCE-CLS"
        .Update
    End With 
End Sub

1 个答案:

答案 0 :(得分:2)

将With行更改为

With rcdDneComments