[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Auto-Fill email address in "Send" Access 97

Posted on 2013-05-30
3
Medium Priority
?
689 Views
Last Modified: 2013-05-31
In the File Menu, the Send item allows me to select which format I want to export the Report in, and then opens the email to send it. I need to auto-fill the To: field with the recipient's email address, which is saved in the account in Access 97. How can I accomplish this without having to manually enter each account's email address in the To field?
0
Comment
Question by:Moshe Singer
  • 2
3 Comments
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 39209315
You can't do that with the builtin menuitems. You'd need to build a routine that would manage this.

You can use DoCmd.SendObject to create an email, and in that you can set the various elements of the email. For example:

DoCmd.SendObject acSendReport, "YourReportName", , "To", , , "Subject", "Message", True

This would create an email and display it to you. Depending on how your report is formatted, you might find this to be somewhat messy (Access doesn't do a good job formatting things like this for email use).

If you need to dynamically fill the "To" section, you can use DLookup for that, assuming you have some way to determine what to look up. For example, if I have an Employees table, and I know the ID of the Employee I want, I'd do this:

Dim sEmail As String

sEmail = DLookup("EmailField", "Employees", "ID=" & Me.ID)

My variable "sEmail" would contain the value retrieved from that table, and I could use it in my SendObject call:

DoCmd.SendObject acSendReport, "YourReportName", , sEmail, , , "Subject", "Message", True

Note that you can change the LAST argument to "False" to automatically send the message.
0
 

Author Comment

by:Moshe Singer
ID: 39209766
Thank you for your reply. However, there is one thing that is still unclear to me. When I use the "Send" menu item, it gives me the option to convert the open report to any of the 4 formats - HTML, Text, Excel, or RTF format.Then it opens Outlook Express and attaches the converted Report to the email.
How can I add to the Code, that it should convert the Report to any format for exporting?
Thanks loads for your previous solution and for your forthcoming help.
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 39210269
You can define the format in the SendObject call in the 3rd argument:

DoCmd.SendObject acSendReport, "YourReportName", acFormatXLS , "To", , , "Subject", "Message", True

Be aware of this also:

"the only controls that are included in the object are text boxes (for .xls files), or text boxes and labels (for .rtf, .txt, and .html files). All other controls are ignored. "

From here: http://msdn.microsoft.com/en-us/library/office/ff197046(v=office.14).aspx

I realize that's from a much newer version, but the same caveats apply. The helpfile included with 97 should show you the valid values you can use for that argument.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question