From: toby131 on
I have visual basic code written in the after update event of a field on the
main form. The form has a subform that has 0-10 records & 3 different
visible fields. I have the code below written to send an email, which runs
successfully. In addition to the current text I would like to be able to
include the entire contents of the subform associated with the record in the
body of the email. Is this possible to do, or if it is not, would it be
possible to include it as an attachment? Thanks!

DoCmd.SendObject , , , recep, , , "Parts Shippment", stemailtext & stwn &
stemailtext2 & sttn

recep: list of email addresses that come from a series of "if" statements
based on main form fields
stemailtext & stwn & stemailtext2 & sttn: current body of the email
comprised of two strings that are standard text saved in earlier code and two
strings that come from fields in the main form.

From: Jack Leach dymondjack at hot mail dot on
I think you would need to make a report of the data in the subform (not too
big of a deal) and send that as an attatchment. This isn't a strong point of
mine, but I believe SendObject can attach the report in a few different
formats (none of which I've found useful, personally).

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"toby131" wrote:

> I have visual basic code written in the after update event of a field on the
> main form. The form has a subform that has 0-10 records & 3 different
> visible fields. I have the code below written to send an email, which runs
> successfully. In addition to the current text I would like to be able to
> include the entire contents of the subform associated with the record in the
> body of the email. Is this possible to do, or if it is not, would it be
> possible to include it as an attachment? Thanks!
>
> DoCmd.SendObject , , , recep, , , "Parts Shippment", stemailtext & stwn &
> stemailtext2 & sttn
>
> recep: list of email addresses that come from a series of "if" statements
> based on main form fields
> stemailtext & stwn & stemailtext2 & sttn: current body of the email
> comprised of two strings that are standard text saved in earlier code and two
> strings that come from fields in the main form.
>
From: toby131 on
Thanks for the input. If I need to send it as a report, how do I make the
report only call the subform records associated with that particular main
form record. They both have ID fields to match them up, but I don't know
where to put that condition when sending the report. When I am opening the
the report there is a parameter for a where condition, but I don't see this
when sending. Thanks!

"Jack Leach" wrote:

> I think you would need to make a report of the data in the subform (not too
> big of a deal) and send that as an attatchment. This isn't a strong point of
> mine, but I believe SendObject can attach the report in a few different
> formats (none of which I've found useful, personally).
>
> hth
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven''t failed, I''ve found ten thousand ways that don''t work."
> -Thomas Edison (1847-1931)
>
>
>
> "toby131" wrote:
>
> > I have visual basic code written in the after update event of a field on the
> > main form. The form has a subform that has 0-10 records & 3 different
> > visible fields. I have the code below written to send an email, which runs
> > successfully. In addition to the current text I would like to be able to
> > include the entire contents of the subform associated with the record in the
> > body of the email. Is this possible to do, or if it is not, would it be
> > possible to include it as an attachment? Thanks!
> >
> > DoCmd.SendObject , , , recep, , , "Parts Shippment", stemailtext & stwn &
> > stemailtext2 & sttn
> >
> > recep: list of email addresses that come from a series of "if" statements
> > based on main form fields
> > stemailtext & stwn & stemailtext2 & sttn: current body of the email
> > comprised of two strings that are standard text saved in earlier code and two
> > strings that come from fields in the main form.
> >
From: Jack Leach dymondjack at hot mail dot on
I *think* that if you use DoCmd.OpenReport in Hidden/Preview mode, and then
use SendObject, and then DoCmd.Close acReport, the SendObject method should
take the open copy of the report (that you will open with a where clause) and
send it. So your code (add appropiate args, I forget their placement...)
would resemble this:

DoCmd.OpenReport ....
DoCmd.SelectObject .... 'for good measure
DoCmd.SendObject ....
DoCmd.Close ....

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"toby131" wrote:

> Thanks for the input. If I need to send it as a report, how do I make the
> report only call the subform records associated with that particular main
> form record. They both have ID fields to match them up, but I don't know
> where to put that condition when sending the report. When I am opening the
> the report there is a parameter for a where condition, but I don't see this
> when sending. Thanks!
>
> "Jack Leach" wrote:
>
> > I think you would need to make a report of the data in the subform (not too
> > big of a deal) and send that as an attatchment. This isn't a strong point of
> > mine, but I believe SendObject can attach the report in a few different
> > formats (none of which I've found useful, personally).
> >
> > hth
> > --
> > Jack Leach
> > www.tristatemachine.com
> >
> > "I haven''t failed, I''ve found ten thousand ways that don''t work."
> > -Thomas Edison (1847-1931)
> >
> >
> >
> > "toby131" wrote:
> >
> > > I have visual basic code written in the after update event of a field on the
> > > main form. The form has a subform that has 0-10 records & 3 different
> > > visible fields. I have the code below written to send an email, which runs
> > > successfully. In addition to the current text I would like to be able to
> > > include the entire contents of the subform associated with the record in the
> > > body of the email. Is this possible to do, or if it is not, would it be
> > > possible to include it as an attachment? Thanks!
> > >
> > > DoCmd.SendObject , , , recep, , , "Parts Shippment", stemailtext & stwn &
> > > stemailtext2 & sttn
> > >
> > > recep: list of email addresses that come from a series of "if" statements
> > > based on main form fields
> > > stemailtext & stwn & stemailtext2 & sttn: current body of the email
> > > comprised of two strings that are standard text saved in earlier code and two
> > > strings that come from fields in the main form.
> > >
From: toby131 on
Thank you that is working just how I was hoping. I don't know if I should be
starting a new post for this, but I had one more question related to this.
One of my fields in the subform I am pulling is a check box. I would like to
be able to set a field on the main form to Complete, Partially Complete, or
Incomplete based on whether all, some, or none of these boxes are checked. I
know I can check the first value with
Me![Subformname].Form.checkboxfieldname
but how do I check all the subform records associated with the main form
record? Thanks!



"Jack Leach" wrote:

> I *think* that if you use DoCmd.OpenReport in Hidden/Preview mode, and then
> use SendObject, and then DoCmd.Close acReport, the SendObject method should
> take the open copy of the report (that you will open with a where clause) and
> send it. So your code (add appropiate args, I forget their placement...)
> would resemble this:
>
> DoCmd.OpenReport ....
> DoCmd.SelectObject .... 'for good measure
> DoCmd.SendObject ....
> DoCmd.Close ....
>
> hth
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven''t failed, I''ve found ten thousand ways that don''t work."
> -Thomas Edison (1847-1931)
>
>
>
> "toby131" wrote:
>
> > Thanks for the input. If I need to send it as a report, how do I make the
> > report only call the subform records associated with that particular main
> > form record. They both have ID fields to match them up, but I don't know
> > where to put that condition when sending the report. When I am opening the
> > the report there is a parameter for a where condition, but I don't see this
> > when sending. Thanks!
> >
> > "Jack Leach" wrote:
> >
> > > I think you would need to make a report of the data in the subform (not too
> > > big of a deal) and send that as an attatchment. This isn't a strong point of
> > > mine, but I believe SendObject can attach the report in a few different
> > > formats (none of which I've found useful, personally).
> > >
> > > hth
> > > --
> > > Jack Leach
> > > www.tristatemachine.com
> > >
> > > "I haven''t failed, I''ve found ten thousand ways that don''t work."
> > > -Thomas Edison (1847-1931)
> > >
> > >
> > >
> > > "toby131" wrote:
> > >
> > > > I have visual basic code written in the after update event of a field on the
> > > > main form. The form has a subform that has 0-10 records & 3 different
> > > > visible fields. I have the code below written to send an email, which runs
> > > > successfully. In addition to the current text I would like to be able to
> > > > include the entire contents of the subform associated with the record in the
> > > > body of the email. Is this possible to do, or if it is not, would it be
> > > > possible to include it as an attachment? Thanks!
> > > >
> > > > DoCmd.SendObject , , , recep, , , "Parts Shippment", stemailtext & stwn &
> > > > stemailtext2 & sttn
> > > >
> > > > recep: list of email addresses that come from a series of "if" statements
> > > > based on main form fields
> > > > stemailtext & stwn & stemailtext2 & sttn: current body of the email
> > > > comprised of two strings that are standard text saved in earlier code and two
> > > > strings that come from fields in the main form.
> > > >