You can use the SendObject action to include the specified Microsoft Office Access 2007 datasheet (datasheet: Data from a table, form, query, view, or stored procedure that is displayed in a row-and-column format.), form (form: An Access database object on which you place controls for taking actions or for entering, displaying, and editing data in fields.), report (report: An Access database object that you can print, which contains information that is formatted and organized according to your specifications. Examples of reports are sales summaries, phone lists, and mailing labels.), module (module: A collection of declarations, statements, and procedures stored together as one named unit. There are two types of modules: standard modules and class modules.), or data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) in an electronic mail message, where it can be viewed and forwarded.
Note This action will not be allowed if the database is not trusted. For more information about enabling macros, see the links in the See Also section of this article.
The SendObject action has the following arguments.
||The type of object to include in the mail message. Click Table (for a table datasheet), Query (for a query datasheet), Form (for a form or form datasheet), Report, Module, or Data Access Page, Server View, Stored Procedures, or Function in the Object Type box in the Action Arguments section of the Macro Builder pane. You can't send a macro (macro: An action or set of actions that you can use to automate tasks.). If you want to include the active object, select its type with this argument, but leave the Object Name argument blank.
The name of the object to include in the mail message. The Object Name box shows all objects in the database of the type selected by the Object Type argument. If you leave both the Object Type and Object Name arguments blank, Access sends a message to the mail application without any database object.
If you run a macro containing the SendObject action in a library database (library database: A collection of procedures and database objects that you can call from any application. In order to use the items in the library, you must first establish a reference from the current database to the library database.), Access looks for the object with this name first in the library database, then in the current database.
The type of format you want used for the included object. The list of formats you can select from will change depending on what you select for the Object Type argument. Available formats may include Excel 97 - Excel 2003 Workbook (*.xls), Excel Binary Workbook (*.xlsb), Excel Workbook (*.xlsx), HTML (*.htm, *.html), Microsoft Excel 5.0/95 Workbook (*.xls), PDF Format, Rich Text Fomat (*.rtf), Text Files (*.txt), or XPS Format (*.xps). in the Output Format box. Modules can be sent only in text format. Data access pages can only be sent in HTML format. If you leave this argument blank, Access prompts you for the output format.
Note You can export to a PDF or XPS format file from Office Access 2007 only after you install the add-in. For more information, seeEnable support for other file formats, such as PDF and XPS.
The recipients of the message whose names you want to put on the To line in the mail message. If you leave this argument blank, Access prompts you for the recipients' names.
Separate the recipients' names you specify in this argument (and in the Cc and Bcc arguments) with a semicolon (;) or with the list separator (separator: A character that separates units of text or numbers.) set on the Number tab of the Regional Settings Properties dialog box in Microsoft Windows Control Panel. If the mail application can't identify the recipients' names, the message isn't sent and an error occurs.
||The message recipients whose names you want to put on the Cc ("carbon copy") line in the mail message. If you leave this argument blank, the Cc line in the mail message is blank.
||The message recipients whose names you want to put on the Bcc ("blind carbon copy") line in the mail message. If you leave this argument blank, the Bcc line in the mail message is blank.
||The subject of the message. This text appears on the Subject line in the mail message. If you leave this argument blank, the Subject line in the mail message is blank.
||Any text you want to include in the message in addition to the database object. This text appears in the main body of the mail message, after the object. If you leave this argument blank, no additional text is included in the mail message. If you leave the Object Type and Object Name arguments blank, you can use this argument to send a mail message without a database object.
||Specifies whether the message can be edited before it's sent. If you select Yes, the electronic mail application starts automatically, and the message can be edited. If you select No, the message is sent without the user having a chance to edit the message. The default is Yes.
||The path and file name of a file you want to use as a template for an HTML file. The template file is a file containing HTML tags.
The object in the mail message is in the selected output format. When you double-click the object, the appropriate software starts with the object opened.
The following rules apply when you use the SendObject action to include a database object in a mail message:
- You can send table, query, and form datasheets. In the included object, all fields (field: An element of a table that contains a specific item of information, such as a last name. A Title field might contain Mr. or Ms. Databases such as Microsoft SQL Server refer to fields as columns.) in the datasheet look as they do in Access, except fields containing OLE objects (OLE object: An object supporting the OLE protocol for object linking and embedding. An OLE object from an OLE server (for example, a Windows Paint picture or a Microsoft Excel worksheet) can be linked or embedded in a field, form, or report.). The columns for these fields are included in the object, but the fields are blank.
- For a control bound to a Yes/No field (a toggle button (toggle button: A control that is used to provide on/off options on a form or report. It can display either text or a picture, and can be stand-alone or part of an option group.), option button (option button: A control, also called a radio button, that is typically used as part of an option group to present alternatives on a form or report. A user cannot select more than one option.), or check box (check box: A control that indicates whether an option is selected. A check mark appears in the box when the option is selected.)), the output file displays the value –1 (Yes) or 0 (No).
- For a text box (text box: A control, also called an edit field, that is used on a form or report to display text or accept data entry. A text box can have a label attached to it.) bound to a Hyperlink (Hyperlink data type: A data type for an Access database field that stores hyperlink addresses. An address can have up to four parts and is written using the following format: displaytext#address#subaddress#.) field, the output file displays the hyperlink (hyperlink: Colored and underlined text or a graphic that you click to go to a file, a location in a file, a Web page on the World Wide Web, or a Web page on an intranet. Hyperlinks can also go to newsgroups and to Gopher, Telnet, and FTP sites.) for all output formats except MS-DOS text (in this case, the hyperlink is just displayed as normal text).
- If you send a form in Form view (Form view: A view that displays a form to show or accept data. Form view is the primary means of adding and modifying data in tables. You can also change the design of a form in this view.), the included object always contains the form's Datasheet view (Datasheet view: A view that displays data from a table, form, query, view, or stored procedure in a row-and-column format. In Datasheet view, you can edit fields, add and delete data, and search for data.).
- If you send a report, the only controls that are included in the object are text boxes and (in some cases) labels. All other controls are ignored. Header and footer information is also not included. The only exception to this is that when you send a report in Excel format, a text box in a group footer containing an expression with the Sum function is included in the object. No other control in a header or footer (and no aggregate function (aggregate function: A function, such as Sum, Count, Avg, or Var, that you use to calculate totals.) other than Sum) is included in the object.
- Subreports (subreport: A report that is contained within another report.) are included in the object.
- When you send a datasheet, form, or data access page in HTML format, one .html file is created. When you send a report in HTML format, one .html file is created for each page in the report.
The SendObject action has the same effect as clicking clicking an object in the Navigation Pane, clicking the Microsoft Office Button , and then clicking E-mail. The action arguments correspond to the settings in the dialog boxes that follow that command. The Send command on the menu only applies only to the active object; however, if you use the SendObject action, you can specify the object you want to send.
To run the SendObject action in a Visual Basic for Applications (VBA) module, use the SendObject method of the DoCmd object.