Push Button to Email form report

  • Thread starter Thread starter Brook
  • Start date Start date
B

Brook

What I am trying to acccomplish is to have the ability to
email a report directly from a form. The form that I will
be using only contains one record based on an ID (CallID).
Does anyone have any ideas on how I can accomplish this? I
have tried to use the SendObject, but this emails an
entire table, query,etc unless I am doing something wrong?

I also have an table that contains my email address that I
will be using unless I can figure a way that the report
will pull directly into MS Outlook for me to choose my
receipient?

Thanks,

Brook
 
Unlike OpenReport, SendObject does not have a WhereCondition to limit the
report to one record.

One workaround is to base the report on a query. In the query, in the
Criteria row under the CallID field, enter:
[Forms].[Form1].[CallID]
replacing "Form1" with the name of your form. This limits the report to just
the record in the form, so the SendObject will pick up just the one record.

Another alternative is to create a public string variable to assign the
filter value to, and apply it in the Report_Open event procedure:
1. At the top of a standard module (with the Option statements), enter:
Dim gstrReportFilter As String

2.In the Click event of the command button on your form, enter this event
procedure:
gstrReportFilter = "CallID = " & Me.CallID
DoCmd.SendObject acSendReport, "Report1", acFormatHTML, _
Subject:="The report", MessageText:="Here tis", EditMEssage:=True

3. In Report_Open:
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = "" 'Reset the public string.
End If

The example above uses the EditMessage argument to cause the email message
to show so you can choose a recipient.
 
When I try to do this my qry is coming up blank? my form
is named frmCallDetails, so I used [Forms].
[FrmCallDetails].[CallID], does this look correct?

Brook

-----Original Message-----
Unlike OpenReport, SendObject does not have a WhereCondition to limit the
report to one record.

One workaround is to base the report on a query. In the query, in the
Criteria row under the CallID field, enter:
[Forms].[Form1].[CallID]
replacing "Form1" with the name of your form. This limits the report to just
the record in the form, so the SendObject will pick up just the one record.

Another alternative is to create a public string variable to assign the
filter value to, and apply it in the Report_Open event procedure:
1. At the top of a standard module (with the Option statements), enter:
Dim gstrReportFilter As String

2.In the Click event of the command button on your form, enter this event
procedure:
gstrReportFilter = "CallID = " & Me.CallID
DoCmd.SendObject acSendReport, "Report1", acFormatHTML, _
Subject:="The report", MessageText:="Here tis", EditMEssage:=True

3. In Report_Open:
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = "" 'Reset the public string.
End If

The example above uses the EditMessage argument to cause the email message
to show so you can choose a recipient.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

What I am trying to acccomplish is to have the ability to
email a report directly from a form. The form that I will
be using only contains one record based on an ID (CallID).
Does anyone have any ideas on how I can accomplish this? I
have tried to use the SendObject, but this emails an
entire table, query,etc unless I am doing something wrong?

I also have an table that contains my email address that I
will be using unless I can figure a way that the report
will pull directly into MS Outlook for me to choose my
receipient?

Thanks,

Brook


.
 
Yes, that looks right.

Perhaps Access is not understanding the data type correctly. If you open
your table in design view, what type of field is CallID? A Text field?
Number? AutoNumber? If Number or AutoNumber, it may help to declare the
parameter in your query. In query design view, select the
[Forms].[FrmCallDetails].[CallID], and copy to clipboard (Ctrl+V). Then
choose Parameters from the Query menu, and paste in the
"[Forms].[FrmCallDetails].[CallID]" bit, specifying the type Long Integer in
the 2nd column.

Presumably you do have the form open and the desired record showing at the
time you are trying to send this.

If the query contains multiple tables and/or other criteria, you may find
the answer in this article:
The Query Lost My Records!
at:
http://allenbrowne.com/casu-02.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Brook said:
When I try to do this my qry is coming up blank? my form
is named frmCallDetails, so I used [Forms].
[FrmCallDetails].[CallID], does this look correct?

Brook

-----Original Message-----
Unlike OpenReport, SendObject does not have a WhereCondition to limit the
report to one record.

One workaround is to base the report on a query. In the query, in the
Criteria row under the CallID field, enter:
[Forms].[Form1].[CallID]
replacing "Form1" with the name of your form. This limits the report to just
the record in the form, so the SendObject will pick up just the one record.

Another alternative is to create a public string variable to assign the
filter value to, and apply it in the Report_Open event procedure:
1. At the top of a standard module (with the Option statements), enter:
Dim gstrReportFilter As String

2.In the Click event of the command button on your form, enter this event
procedure:
gstrReportFilter = "CallID = " & Me.CallID
DoCmd.SendObject acSendReport, "Report1", acFormatHTML, _
Subject:="The report", MessageText:="Here tis", EditMEssage:=True

3. In Report_Open:
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = "" 'Reset the public string.
End If

The example above uses the EditMessage argument to cause the email message
to show so you can choose a recipient.

What I am trying to acccomplish is to have the ability to
email a report directly from a form. The form that I will
be using only contains one record based on an ID (CallID).
Does anyone have any ideas on how I can accomplish this? I
have tried to use the SendObject, but this emails an
entire table, query,etc unless I am doing something wrong?

I also have an table that contains my email address that I
will be using unless I can figure a way that the report
will pull directly into MS Outlook for me to choose my
receipient?

Thanks,

Brook
 
Yes, the CallID is an AutoNumber primary Key...

Brook
-----Original Message-----
Yes, that looks right.

Perhaps Access is not understanding the data type correctly. If you open
your table in design view, what type of field is CallID? A Text field?
Number? AutoNumber? If Number or AutoNumber, it may help to declare the
parameter in your query. In query design view, select the
[Forms].[FrmCallDetails].[CallID], and copy to clipboard (Ctrl+V). Then
choose Parameters from the Query menu, and paste in the
"[Forms].[FrmCallDetails].[CallID]" bit, specifying the type Long Integer in
the 2nd column.

Presumably you do have the form open and the desired record showing at the
time you are trying to send this.

If the query contains multiple tables and/or other criteria, you may find
the answer in this article:
The Query Lost My Records!
at:
http://allenbrowne.com/casu-02.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

When I try to do this my qry is coming up blank? my form
is named frmCallDetails, so I used [Forms].
[FrmCallDetails].[CallID], does this look correct?

Brook

-----Original Message-----
Unlike OpenReport, SendObject does not have a WhereCondition to limit the
report to one record.

One workaround is to base the report on a query. In the query, in the
Criteria row under the CallID field, enter:
[Forms].[Form1].[CallID]
replacing "Form1" with the name of your form. This
limits
the report to just
the record in the form, so the SendObject will pick up just the one record.

Another alternative is to create a public string
variable
to assign the
filter value to, and apply it in the Report_Open event procedure:
1. At the top of a standard module (with the Option statements), enter:
Dim gstrReportFilter As String

2.In the Click event of the command button on your
form,
enter this event
procedure:
gstrReportFilter = "CallID = " & Me.CallID
DoCmd.SendObject acSendReport, "Report1", acFormatHTML, _
Subject:="The report", MessageText:="Here tis", EditMEssage:=True

3. In Report_Open:
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = "" 'Reset the public string.
End If

The example above uses the EditMessage argument to
cause
the email message
to show so you can choose a recipient.

What I am trying to acccomplish is to have the
ability
to
email a report directly from a form. The form that I will
be using only contains one record based on an ID (CallID).
Does anyone have any ideas on how I can accomplish this? I
have tried to use the SendObject, but this emails an
entire table, query,etc unless I am doing something wrong?

I also have an table that contains my email address that I
will be using unless I can figure a way that the report
will pull directly into MS Outlook for me to choose my
receipient?

Thanks,

Brook


.
 
Back
Top