Hi,
I seem to be having trouble with the getNext method. In my routine I'm
simply trying to read out the first 10 entries in my folder. I go to the
first record, then enter a for loop and loop 10 times using getNext.
Problem is that it shows one record, then the next and then it keeps showing
the same record for the 10 iterations. Am I doing something wrong in my
code? Here it is:
Set myolApp.ActiveExplorer.CurrentFolder = _
myNamespace.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("Deliveries")
Set orgDeliveriesFolder =
myNamespace.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("Deliveries")
Set PatientRecord = orgDeliveriesFolder.Items().GetFirst
MsgBox ("Deliveries Folder Name = " & orgDeliveriesFolder.Name _
& Chr(13) & "No. of Patients = " &
orgDeliveriesFolder.Items().Count)
For I = 1 To 10
MsgBox ("Patient Name = " & PatientRecord.Subject & Chr(13) & _
"Location = " & PatientRecord.Location & Chr(13) & _
"Start = " & PatientRecord.Start & Chr(13) & _
"Categories = " & PatientRecord.Categories + Chr(13) & _
"Message = " & PatientRecord.Body)
' "Assessment Due = " & PatientRecord.UserProperties.Find("Assessment
Due") & Chr(13) & _
Set PatientRecord = orgDeliveriesFolder.Items().GetNext
Next I
Thanks in advance,
Linn
Sue Mosher [MVP-Outlook] - 28 Oct 2005 17:16 GMT
You need an explicit Items object and should use GetFirst to get the first item:
Set delItems = orgDeliveriesFolder.Items
Set PatientRecord = delItems.GetFirst
For I = 1 To 9
' do stuff with PatientRecord
Set PatientRecord = orgDeliveriesFolder.Items().GetNext
Next I

Signature
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
> Hi,
>
[quoted text clipped - 31 lines]
> Thanks in advance,
> Linn
Dan Mitchell - 28 Oct 2005 17:23 GMT
> I seem to be having trouble with the getNext method. In my routine
> I'm simply trying to read out the first 10 entries in my folder. I go
[quoted text clipped - 5 lines]
> [...]
> Set PatientRecord = orgDeliveriesFolder.Items().GetNext
That's because you're calling Items().GetNext -- each time you call Items
(), you get a fresh instance of that thing, so each GetNext() call starts
from the beginning.
You need to move Items() out of the loop and assign it to a variable
there; that way it'll be the same one that has GetNext() called on it each
time.
-- dan
Linn Kubler - 28 Oct 2005 18:02 GMT
>> I seem to be having trouble with the getNext method. In my routine
>> I'm simply trying to read out the first 10 entries in my folder. I go
[quoted text clipped - 15 lines]
>
> -- dan
Yes, thanks that was the trick. Looks like it's working now.
Thanks much!
Linn