Moving form data to mail message body

  • Thread starter golfdog via AccessMonster.com
  • Start date
G

golfdog via AccessMonster.com

Have a form with two subforms. Attempting to generate a email message off the
form. So far am successful with the main form data being built into the email
body, now trying to loop through the related records from the subforms as
they can have multiple related records to the main form and include that in
the email message body.

I am throwing an error on this part of the code.....

' Groups Detail
' This routine loops through all the group details which belong to this
particular request
Set RSGroupQry = CurrentDb.QueryDefs("q_ReqGrp")
Set RSGroups = RSGroupQry.OpenRecordset()
RSGroupQry.Parameters("ReqNo") = Me!ReqNo
lngRSGroupsCount = RSGroups.RecordCount
If lngRSGroupsCount = 0 Then
strBody = strBody & "No Groups Associated With This Request" & vbCrLf &
vbCrLf
Else
RSGroups.MoveFirst

Do Until RSGroups.EOF

strGroupsText = RSGroups!GrpType & " " & RSGroups!Grp
strBody = strBody & strGroupsText & vbCrLf
RSGroups.MoveNext
Loop

Appreciate it.
RSGroups.Close
Set RSGroups = Nothing
End If
 
G

golfdog via AccessMonster.com

golfdog said:
Have a form with two subforms. Attempting to generate a email message off the
form. So far am successful with the main form data being built into the email
body, now trying to loop through the related records from the subforms as
they can have multiple related records to the main form and include that in
the email message body.

I am throwing an error on this part of the code.....

' Groups Detail
' This routine loops through all the group details which belong to this
particular request
Set RSGroupQry = CurrentDb.QueryDefs("q_ReqGrp")
Set RSGroups = RSGroupQry.OpenRecordset()
RSGroupQry.Parameters("ReqNo") = Me!ReqNo
lngRSGroupsCount = RSGroups.RecordCount
If lngRSGroupsCount = 0 Then
strBody = strBody & "No Groups Associated With This Request" & vbCrLf &
vbCrLf
Else
RSGroups.MoveFirst

Do Until RSGroups.EOF

strGroupsText = RSGroups!GrpType & " " & RSGroups!Grp
strBody = strBody & strGroupsText & vbCrLf
RSGroups.MoveNext
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top