A
aspoede
Hi,
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
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