Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .openpublishing.redirection.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@
{
"source_path": "access/Concepts/Maintenance/recover-tables-deleted-from-a-database.md",
"redirect_url": "/office/vba/access/concepts/miscellaneous/recover-tables-deleted-from-a-database"
},
{
"source_path": "access/Concepts/Settings/data-access-objects-dao.md",
"redirect_url": "/office/vba/api/overview/access"
},
{
"source_path": "access/Concepts/Settings/activex-data-objects-ado.md",
"redirect_url": "/office/vba/api/overview/access"
}

]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: Close a Report Automatically If It Does Not Contain Any Records
title: Close a report automatically if it does not contain any records
ms.prod: access
ms.assetid: 9b160bd3-6eca-f907-ae5b-4327c3c1618e
ms.date: 06/08/2017
ms.date: 09/26/2018
---


# Close a Report Automatically If It Does Not Contain Any Records
# Close a report automatically if it does not contain any records

The following example shows how to use the **[NoData](../../../api/Access.Report.NoData.md)** event to cancel opening or printing a report when it has no data. A message box notifying the user that the report has no data is also displayed.
The following example shows how to use the **[NoData](../../../api/Access.Report.NoData.md)** event to cancel opening or printing a report when it has no data. A message box notifying the user that the report has no data is also displayed.


```vb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: Filter a Report Using a Form's Filter
title: Filter a report using a form's filter
ms.prod: access
ms.assetid: 2b029c13-5abd-4865-cd05-25d094a97b9f
ms.date: 06/08/2017
ms.date: 09/26/2018
---


# Filter a Report Using a Form's Filter
# Filter a report using a form's filter

The following example illustrates how to open a report based on the filtered contents of a form. To do this, specify the form's **[Filter](../../../api/Access.Form.Filter(property).md)** property as the value of the **[OpenReport](../../../api/Access.DoCmd.OpenReport.md)** method's _WhereCondition_ argument.
The following example illustrates how to open a report based on the filtered contents of a form. To do this, specify the form's **[Filter](../../../api/Access.Form.Filter(property).md)** property as the value of the **[OpenReport](../../../api/Access.DoCmd.OpenReport.md)** method's _WhereCondition_ argument.


```vb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
---
title: Programmatically Retrieve Printer Capabilities
title: Programmatically retrieve printer capabilities
ms.prod: access
ms.assetid: 8c929823-6b61-16ea-6d84-ff47cc1e8389
ms.date: 06/08/2017
ms.date: 09/26/2018
---


# Programmatically Retrieve Printer Capabilities
# Programmatically retrieve printer capabilities

The **[Printers](../../../api/Access.Printers.md)** collection and **[Printer](../../../api/Access.Printer.md)** object allow you only to set or retrieve settings for a printer. To determine a printer's capabilities, such as the kinds of paper or paper bins it supports, you must use calls to the Windows Application Programming Interface (API) **DeviceCapabilities** function. It is beyond the scope of this topic to cover this in detail, but the following code sample from the modPrinters module of the PrinterDemo.mdb sample download demonstrates how to retrieve the names and IDs of the supported paper size and paper bins for a printer.
The **[Printers](../../../api/Access.Printers.md)** collection and **[Printer](../../../api/Access.Printer.md)** object allow you only to set or retrieve settings for a printer. To determine a printer's capabilities, such as the kinds of paper or paper bins it supports, you must use calls to the Windows Application Programming Interface (API) **DeviceCapabilities** function. It is beyond the scope of this topic to cover this in detail, but the following code sample from the modPrinters module of the PrinterDemo.mdb sample download demonstrates how to retrieve the names and IDs of the supported paper size and paper bins for a printer.

The following code should be pasted into the general declarations section of a module.



```vb
' Declaration for the DeviceCapabilities function API call.
Private Declare Function DeviceCapabilities Lib "winspool.drv" _
Expand All @@ -30,9 +28,9 @@ Private Const DEFAULT_VALUES = 0

```

The following procedure uses the **DeviceCapabilities** API function to display a message box with the name of the default printer and a list of the paper sizes it supports.

<br/>

The following procedure uses the **DeviceCapabilities** API function to display a message box with the name of the default printer and a list of the paper sizes it supports.

```vb
Sub GetPaperList()
Expand Down Expand Up @@ -110,9 +108,9 @@ GetPaperList_Err:
End Sub
```

The following procedure uses the **DeviceCapabilities** API function to display a message box with the name of the default printer and a list of the paper bins it supports.

<br/>

The following procedure uses the **DeviceCapabilities** API function to display a message box with the name of the default printer and a list of the paper bins it supports.

```vb
Sub GetBinList(strName As String)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
title: Retrieve a List of Installed Printers
title: Retrieve a list of installed printers
ms.prod: access
ms.assetid: e3162c3e-6b5b-77c3-32f9-1fdfa64cdefc
ms.date: 06/08/2017
ms.date: 09/26/2018
---


# Retrieve a List of Installed Printers
# Retrieve a list of installed printers

You use the **[Printers](../../../api/Access.Application.Printers.md)** property of the **[Application](../../../api/Access.Application.md)** object to return the **[Printers](../../../api/Access.Printers.md)** collection. The following procedure illustrates how to enumerate through each **Printer** object in the **Printers** collection by using a **For Each…Next** statement. A message box is displayed with information about each installed printer.
You use the **[Printers](../../../api/Access.Application.Printers.md)** property of the **[Application](../../../api/Access.Application.md)** object to return the **[Printers](../../../api/Access.Printers.md)** collection.

The following procedure illustrates how to enumerate through each **Printer** object in the **Printers** collection by using a **For Each…Next** statement. A message box is displayed with information about each installed printer.

```vb
Sub ShowPrinters()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
---
title: Work with Form and Report Printer Settings
title: Work with form and report printer settings
ms.prod: access
ms.assetid: 14a8aa00-9ad8-60f7-e103-791ab08c0e9e
ms.date: 06/08/2017
ms.date: 09/26/2018
---


# Work with Form and Report Printer Settings
# Work with form and report printer settings

The **[Printer](../../../api/Access.Printer.md)** objects associated with **[Form](../../../api/Access.Form.md)** and **[Report](../../../api/Access.Report.md)** objects support the same properties and programming techniques as the **[Application](../../../api/Access.Application.md)** object's **Printer** object. Use the **Printer** object of a **Form** or **Report** object when you want to set or retrieve printer settings for a specific form or report. You can change form and report printer settings temporarily, or you can save those settings with the form or report.
The **[Printer](../../../api/Access.Printer.md)** objects associated with **[Form](../../../api/Access.Form.md)** and **[Report](../../../api/Access.Report.md)** objects support the same properties and programming techniques as the **[Application](../../../api/Access.Application.md)** object's **Printer** object.

Use the **Printer** object of a **Form** or **Report** object when you want to set or retrieve printer settings for a specific form or report. You can change form and report printer settings temporarily, or you can save those settings with the form or report.

## Saving Printer Settings with a Form or Report

Whether a form or report uses the settings of the default application printer (the settings managed with the **Application** object's **Printer** object) is determined by whether the form or report has previously saved printer settings. Printer settings for a form or report can be saved two ways:
## Save printer settings with a form or report

Whether a form or report uses the settings of the default application printer (the settings managed with the **Application** object's **Printer** object) is determined by whether the form or report has previously saved printer settings. Printer settings for a form or report can be saved two ways:

- A user can save printer settings by opening the form or report in any view, and using the **Print** or **Page Setup** dialog boxes to change the settings for the form or report.
- A user can save printer settings by opening the form or report in any view, and using the **Print** or **Page Setup** dialog boxes to change the settings for the form or report.

- You can make changes to the **Printer** object of a form or report in code, and those changes will be saved with the form or report if you use the **[Save](../../../api/Access.DoCmd.Save.md)** method before closing the form or report, or specify **acSaveYes** for the _Save_ argument when using the **[Close](../../../api/Access.DoCmd.Close.md)** method to close the form or report.


**Note** When printer settings are saved with a form or report, Access creates a new data structure for the form or report to contain the saved settings. Initially, this new data structure contains a copy of all of the settings of the default printer. Any settings the user or your code overrides are saved with the data structure. Access does not maintain any sort of inheritance between settings of the default printer and the settings saved with a form or report. If you change settings of the default printer after saving settings for a form or report, the settings that were originally saved will remain in effect.
- You can make changes to the **Printer** object of a form or report in code, and those changes will be saved with the form or report if you use the **[Save](../../../api/Access.DoCmd.Save.md)** method before closing the form or report, or specify **acSaveYes** for the _Save_ argument when using the **[Close](../../../api/Access.DoCmd.Close.md)** method to close the form or report.

> [!NOTE]
> When printer settings are saved with a form or report, Access creates a new data structure for the form or report to contain the saved settings. Initially, this new data structure contains a copy of all of the settings of the default printer. Any settings the user or your code overrides are saved with the data structure.
>
> Access does not maintain any sort of inheritance between settings of the default printer and the settings saved with a form or report. If you change settings of the default printer after saving settings for a form or report, the settings that were originally saved will remain in effect.

## Determining Whether a Form or Report Has Saved Printer Settings

To determine whether a form or report has saved printer settings, you can read the **UseDefaultPrinter** property of a **Form** or **Report** object using the following syntax:
## Determine whether a form or report has saved printer settings

To determine whether a form or report has saved printer settings, you can read the **UseDefaultPrinter** property of a **Form** or **Report** object by using the following syntax, where _expression_ is any expression that returns a **Form** or **Report** object.

```vb
expression .UseDefaultPrinter

```

Where _expression_ is any expression that returns a **Form** or **Report** object. The **UseDefaultPrinter** property is read/write in Design view and read-only in all other views.


## Clearing Saved Printer Settings

You can also use the **UseDefaultPrinter** property like a method to clear saved settings from a form or report by setting its value to **True**. This is equivalent to opening the **Page Setup** dialog box for the form or report and selecting **Default Printer** on the **Page** tab.
The **UseDefaultPrinter** property is read/write in Design view and read-only in all other views.

You can set the **UseDefaultPrinter** property only when a form or report is open in Design view. The following code fragment opens each of the reports in the current project and clears any report that has saved settings.

## Clear saved printer settings

You can also use the **UseDefaultPrinter** property like a method to clear saved settings from a form or report by setting its value to **True**. This is equivalent to opening the **Page Setup** dialog box for the form or report and selecting **Default Printer** on the **Page** tab. You can set the **UseDefaultPrinter** property only when a form or report is open in Design view.

The following code fragment opens each of the reports in the current project and clears any report that has saved settings.

```vb
For Each obj In CurrentProject.AllReports
Expand All @@ -59,10 +58,11 @@ Next obj
```


## Preserving Form and Report Printer Settings
## Preserve form and report printer settings

When you programmatically change printer property settings for forms or reports while the object is in any view other than Design view, those changes are automatically saved if the user interactively closes the form or report. The following procedure demonstrates how to save and restore a report's printer settings.
When you programmatically change printer property settings for forms or reports while the object is in any view other than Design view, those changes are automatically saved if the user interactively closes the form or report.

The following procedure demonstrates how to save and restore a report's printer settings.

```vb
Sub RestoreReportPrinter()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
---
title: Create Alternating Row Colors on a Report
title: Create alternating row colors on a report
ms.prod: access
ms.assetid: ea37a0cb-9057-e268-28a7-183751c8a1b8
ms.date: 06/08/2017
ms.date: 09/26/2018
---


# Create Alternating Row Colors on a Report
# Create alternating row colors on a report

By default, Access formats each row of a report's detail section with the same background color. When printing a report, shading every other line of the detail section can make it much easier to read. You can use the **[AlternateBackColor](../../../api/Access.Section.AlternateBackColor.md)** property to specify a color to be displayed or printed on every other line in the detail section when viewing or printing a report.

The following example illustrates how to display light gray bars on every other line of the report's detail section when it is printed.



```vb
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: Set Form, Report, and Control Properties in Code
title: Set form, report, and control properties in code
ms.prod: access
ms.assetid: 23d88ab3-9ee6-5f7f-2351-14bb94d7a27b
ms.date: 06/08/2017
ms.date: 09/26/2018
---


# Set Form, Report, and Control Properties in Code
# Set form, report, and control properties in code

**[Form](../../../api/Access.Form.md)**, **[Report](../../../api/Access.Report.md)**, and **[Control](../../../api/Access.Control.md)** objects are Access objects. You can set properties for these objects from within a **Sub**, **Function**, or event procedure. You can also set properties for form and report sections.


## To set a property of a form or report
## Set a property of a form or report

Refer to the individual form or report within the **[Forms](../../../api/Access.Forms.md)** or **[Reports](../../../api/Access.Reports.md)** collection, followed by the name of the property and its value. For example, to set the **[Visible](../../../api/Access.Form.Visible.md)** property of the Customers form to **True** (-1), use the following line of code:

Expand All @@ -29,7 +29,7 @@ Me.RecordSource = "SELECT * FROM Customers " _
```


## To set a property of a control
## Set a property of a control

Refer to the control in the **[Controls](../../../api/Access.Form.Controls.md)** collection of the **Form** or **Report** object on which it resides. You can refer to the **Controls** collection either implicitly or explicitly, but the code executes faster if you use an implicit reference. The following examples set the **Visible** property of a text box called CustomerID on the Customers form:

Expand All @@ -54,7 +54,7 @@ End With
```


## To set a property of a form or report section
## Set a property of a form or report section

Refer to the form or report within the **Forms** or **Reports** collection, followed by the **Section** property and the integer or constant that identifies the section. The following examples set the **Visible** property of the page header section of the Customers form to **False**:

Expand All @@ -69,14 +69,14 @@ Me!Section(acPageHeader).Visible = False
```


- For each property you want to set, you can look up the property in the Help index to find information about:
For each property you want to set, you can look up the property in the Help index to find information about:

- Whether you can set the property from Visual Basic.
- Whether you can set the property from Visual Basic.

- Views in which you can set the property. Not all properties can be set in all views. For example, you can set a form's **BorderStyle** property only in form Design view.
- Views in which you can set the property. Not all properties can be set in all views. For example, you can set a form's **BorderStyle** property only in form Design view.

- Which values you should use to set the property. You often use different settings when you set a property in Visual Basic instead of in the property sheet. For example, if the property settings are selections from a list, you must use the value or numeric equivalent for each selection.
- Which values you should use to set the property. You often use different settings when you set a property in Visual Basic instead of in the property sheet. For example, if the property settings are selections from a list, you must use the value or numeric equivalent for each selection.

- To set default properties for controls from Visual Basic, use the **DefaultControl** property.
To set default properties for controls from Visual Basic, use the **DefaultControl** property.


17 changes: 0 additions & 17 deletions access/Concepts/Settings/activex-data-objects-ado.md

This file was deleted.

Loading