[AccessD] Deleting Outlook Contacts

Charlotte Foust charlotte.foust at gmail.com
Thu Sep 9 20:38:53 CDT 2010


Rocky,

To get deletes to work properly, you have to move backwards through
the recordset.   Instead of using For Each, try moving to the last
record first and do until EOF and BOF.

Charlotte Foust

On Thu, Sep 9, 2010 at 8:25 AM, Rocky Smolin <rockysmolin at bchacc.com> wrote:
> Dear List:
>
> Still struggling with deleting the Outlook contacts.  I found that looping
> through the items and deleting them deleted half so if I started with 1000
> contacts at the end of the loop I had 500 left.  If I sent the program back
> through the loop I ended up with 250.  etc.
>
> So iterating that loop until the Count = 0 works but it's kludgey.  Why does
> it leave half of the contacts behind each time?
>
> Here's the code:
>
>    ' delete all the current contacts
>    Set olContacts = olFolder.Items
> DeleteAgain:
>    Me.txtProcessing = "Deleting..." & olContacts.Count
>    Me.Repaint
>    For Each olContactItem In olContacts
>        'MsgBox olContactItem.LastName & ", " & olContactItem.FirstName & "
> - " & olContacts.Count
>        olContactItem.Delete
>        DoEvents
>    Next
>    Set olContacts = olFolder.Items
>    If olContacts.Count <> 0 Then GoTo DeleteAgain:
>
>
> Me.txtProcessing displays the number of contacts each time through the big
> loop.  So that's how I know it's only deleting 1/2 each time. When I
> uncomment the MsgBox line inside the loop, it shows the count going to zero
> each time the loop executes.  But after the loop finishes, there's still 1/2
> the contacts left.  refreshing the count by Set olContacts = olFolder.Items
> gives the right count again.
>
> Any idea what the heck is going on here?
>
>
>
> MTIA
>
>
>
> Rocky
>
>
>
>
> -




More information about the AccessD mailing list