[AccessD] Deleting Outlook Contacts

Stuart McLachlan stuart at lexacorp.com.pg
Fri Sep 10 06:02:45 CDT 2010


Unless mycol() decides to be one based like Outlook folder items as Rocky discovered. :-)

-- 
Stuart

On 10 Sep 2010 at 6:09, jwcolby wrote:

>  > In short, when you delete the contact, the next record becomes the
>  current one.  That one is 
> skipped as you do a "move next" to get to the next record, effectively
> skipping the 'new' current record.  This is why only half are removed.
>  Or at least that is my understanding of it.  You certainly see that
> sort of behaviour in Excel when using that sort of method to delete
> records.
> 
> 
> That is why I do something like
> 
> while MyCol.Count
>  MyCol(0).remove
> wend
> 
> John W. Colby
> www.ColbyConsulting.com
> 
> On 9/9/2010 9:59 PM, Darryl Collins wrote:
> >
> > ____________________________________________________________________
> > ___________________
> >
> > Note: This e-mail is subject to the disclaimer contained at the
> > bottom of this message.
> > ____________________________________________________________________
> > ___________________
> >
> >
> >
> >
> > In short, when you delete the contact, the next record becomes the
> > current one.  That one is skipped as you do a "move next" to get to
> > the next record, effectively skipping the 'new' current record. 
> > This is why only half are removed.  Or at least that is my
> > understanding of it.  You certainly see that sort of behaviour in
> > Excel when using that sort of method to delete records.
> >
> > regards
> > Darryl.
> >
> > -----Original Message-----
> > From: accessd-bounces at databaseadvisors.com
> > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte
> > Foust Sent: Friday, 10 September 2010 11:39 AM To: Access Developers
> > discussion and problem solving Subject: Re: [AccessD] Deleting
> > Outlook Contacts
> >
> > 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
> >>
> >>
> >>
> >>
> >> -
> >
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 





More information about the AccessD mailing list