force new record in loop

F

fgibbcollins

I've created a form that captures a selected email from an Outlook View
Control, copies its sender, subject and body into a memo field; then extracts
attachments to a specified folder. I have a subform that is meant to hold a
hyperlink to the downloaded attachment, but if there are multiple attachments
then it simply copies over the first attachment path. How can I force it to
move to the next record? I tried inserting a Gotorecord, acnew, but it tells
me the subform isn't open. Any help would be greatly appreciated. Thanks,
Frank
Here is my code:
With OutlookViewCtl

Set CopyItem = OutlookViewCtl.Selection
Set sMail = CreateObject("Redemption.SafeMailItem")
i = 0
For Each itm In CopyItem
sMail.item = itm
Notes = "**Received Email**" & vbCrLf & "From: " & sMail.SenderName
& vbCrLf & "To: " & sMail.ReceivedByName & vbCrLf & sMail.Body & vbCrLf &
"CCed: " & sMail.CC
NotesDate = sMail.ReceivedTime
Form_frmContactWith!ContactWith = sMail.SenderName
For Each att In itm.Attachments
FileName = "C:\Utility Relocation\Job Folders\" &
Form_frmMainDetails!JobNumber & "\" & NotesPK & "_" & att.DisplayName
att.SaveAsFile FileName

Me!frmIncomingAttachments!IncomingAttachment = FileName
Me!frmIncomingAttachments!NotesIncomingAttFK = Me!NotesPK

i = i + 1
Next att
Next itm


End With
 
M

Michael J. Strickland

fgibbcollins said:
I've created a form that captures a selected email from an Outlook View
Control, copies its sender, subject and body into a memo field; then
extracts
attachments to a specified folder. I have a subform that is meant to hold
a
hyperlink to the downloaded attachment, but if there are multiple
attachments
then it simply copies over the first attachment path. How can I force it
to
move to the next record? I tried inserting a Gotorecord, acnew, but it
tells
me the subform isn't open. Any help would be greatly appreciated.
Thanks,
Frank
Here is my code:
With OutlookViewCtl

Set CopyItem = OutlookViewCtl.Selection
Set sMail = CreateObject("Redemption.SafeMailItem")
i = 0
For Each itm In CopyItem
sMail.item = itm
Notes = "**Received Email**" & vbCrLf & "From: " &
sMail.SenderName
& vbCrLf & "To: " & sMail.ReceivedByName & vbCrLf & sMail.Body & vbCrLf &
"CCed: " & sMail.CC
NotesDate = sMail.ReceivedTime
Form_frmContactWith!ContactWith = sMail.SenderName
For Each att In itm.Attachments
FileName = "C:\Utility Relocation\Job Folders\" &
Form_frmMainDetails!JobNumber & "\" & NotesPK & "_" & att.DisplayName
att.SaveAsFile FileName

Me!frmIncomingAttachments!IncomingAttachment = FileName
Me!frmIncomingAttachments!NotesIncomingAttFK = Me!NotesPK

i = i + 1
Next att
Next itm


End With


I'm not to up on memo fields but, try concatenating each "FileName" onto the
end of your memo field (IncomingAttachment) instead of setting the memo
field to the current attachment filename.

Replace:
Me!frmIncomingAttachments!IncomingAttachment = FileName

with:

Me!frmIncomingAttachments!IncomingAttachment = _
Me!frmIncomingAttachments!IncomingAttachment & vbcrlf & FileName

This should put the hyperlinks on on separate lines in the same memo field
(& record).

--
 
Top