tags:

views:

71

answers:

1

Hi,
When I am trying to execute the program I am getting an error like "operation is not allowed when the object is open".

I am geeting error in second part of the code where .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
+2  A: 

Change the With line to

With rcdDneComments
Lance Roberts
Thanks. I didn't see that. Its working now. Tha ks for your help.
pbrp