Re: Adding multiple subform fields to a mail item in Access
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Wed, 23 Nov 2005 10:21:51 +0800
Use the MoveNext method of the Recordset to get to the next record.
To ensure the recordset pointer is at the top, you need to MoveFirst before
the loop starts. The MoveFirst will fail if there are no records, so try
something like this:
Dim rst As DAO.Recordset
Dim strSubject As String
Set rst = Forms![RMA Entry]![Part Count subform].Form.RecordsetClone
With rst
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF
strSubject = strSubject & [CountOfPART NAME] & " x " & [PART
NAME] & " "
.MoveNext
Loop
End If
End With
myItem.Subject = Trim(strSubject)
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
<aspoede@xxxxxxxxx> wrote in message
news:1132707657.419301.150800@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> I am trying to send an email from an Access form with the Subject line
> populated with fields from a subform. The tricky part is that the
> number of records in that subform changes and I need it to populate the
> subject line with as many records listed. I can populated the first
> record ok, but I can't seem to move to the next record. I think I need
> to clone the record set and put in a loop somewhere, but what I've got
> doesn't generate any information.
>
> My code:
>
> Private Sub RMAsend_Click()
>
> Set myOlApp = CreateObject("Outlook.Application")
> Set myItem = myOlApp.CreateItem(olMailItem)
>
> myItem.SentOnBehalfOfName = "Technical Support"
> myItem.To = "RMA"
> myItem.Subject = "RMA " & [RMA NUMBER] & " - " & Me![RMA DATA
> subform1].Form![company] & " - "
>
> Forms![RMA Entry]![Part Count subform].SetFocus
> Dim rst As DAO.Recordset
> Set rst = Forms![RMA Entry]![Part Count
> subform].Form.RecordsetClone
> With rst
> Do Until .EOF
> myItem.Subject = myItem.Subject & [CountOfPART NAME] & " x " &
> [PART NAME] & " "
> DoCmd.GoToRecord , , acNext
> Loop
> End With
.
- Follow-Ups:
- References:
- Adding multiple subform fields to a mail item in Access
- From: aspoede
- Adding multiple subform fields to a mail item in Access
- Prev by Date: Re: text scroll
- Next by Date: Re: Border on image?
- Previous by thread: Adding multiple subform fields to a mail item in Access
- Next by thread: Re: Adding multiple subform fields to a mail item in Access
- Index(es):
Relevant Pages
|