sending email from access

G

Guest

I have a command button on a form that I want to use to send and email using
outlook express and automatically insert the address from the email field of
the current record. I have no trouble starting Outlook express, but how do I
transfer the address? I am not trying to send a report or other document
from the database, I just want to open OE and insert the address.
 
A

Allen Browne

SendObject lets you create an email:

DoCmd.SendObject acSendNoObject, To:="fred.somewhere.com", _
Subject:="Hello", MessageText:="This is the message", EditMessage:= True
 
J

jlk

I need to email a report regarding only one item just as I would send this
report page to the printer.

The DoCmd.SendObject command has no where clause so a script like
DoCmd.SendObject acReport "rptInvoice", .......
would send a complete listing to as an email attachment.

I have not found a way to trim the complete report to the record that has to
be sent.
Would someone have a workaround for me?

I work with access 2000 and 2003.
Hans
 
A

Allen Browne

Create a public string variable, and use the Open event of the report to
read and apply the string as the filter.

1. On the Modules tab of the Database Window, click New.
Access opens a new module.
In the General Declarations (just under the Option statements), enter:
Dim gstrReportFilter As String
Save with a name such as "Module1".
Close.

2. Open your report in design view.
Set the On Open property (Event tab of properties box) to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.
Enter this kind of thing:

Private Sub Report_Open(Cancel As Integer)
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = vbNullString
End If
End Sub

3. Set the filter string before you open your report.
It will be just like the WhereCondition of OpenReport.
Example:
gstrReportFilter = "[InvoiceID] = 73"
DoCmd.SendObject acReport "rptInvoice", .......
 
J

jlk

Thanks alot !!!


Hans



Allen Browne said:
Create a public string variable, and use the Open event of the report to
read and apply the string as the filter.

1. On the Modules tab of the Database Window, click New.
Access opens a new module.
In the General Declarations (just under the Option statements), enter:
Dim gstrReportFilter As String
Save with a name such as "Module1".
Close.

2. Open your report in design view.
Set the On Open property (Event tab of properties box) to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.
Enter this kind of thing:

Private Sub Report_Open(Cancel As Integer)
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = vbNullString
End If
End Sub

3. Set the filter string before you open your report.
It will be just like the WhereCondition of OpenReport.
Example:
gstrReportFilter = "[InvoiceID] = 73"
DoCmd.SendObject acReport "rptInvoice", .......

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

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

jlk said:
I need to email a report regarding only one item just as I would send this
report page to the printer.

The DoCmd.SendObject command has no where clause so a script like
DoCmd.SendObject acReport "rptInvoice", .......
would send a complete listing to as an email attachment.

I have not found a way to trim the complete report to the record that has
to be sent.
Would someone have a workaround for me?

I work with access 2000 and 2003.
Hans
 

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